summaryrefslogtreecommitdiff
path: root/gio/gnetworkaddress.c
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2014-03-10 16:27:48 +0100
committerDan Winship <danw@gnome.org>2014-04-02 11:23:29 -0400
commit20feb23569e61b061b507e995b5438a35676ae51 (patch)
treea41656f545b6314521eeed516ca7e514cf651935 /gio/gnetworkaddress.c
parent8d037c678d8d3d0c0e4e1ddb22e47306567ed88a (diff)
downloadglib-20feb23569e61b061b507e995b5438a35676ae51.tar.gz
networkaddress: fix parsing of uri with @ after authority
Make sure that the @ sign is inside the authority part before attempting to parse the userinfo. We do this by checking if the @ sign comes before any of the possible authority delimiters. Add unit test to verify parsing of ftp://ftp.gnome.org/start?foo=bar@baz https://bugzilla.gnome.org/show_bug.cgi?id=726040
Diffstat (limited to 'gio/gnetworkaddress.c')
-rw-r--r--gio/gnetworkaddress.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gio/gnetworkaddress.c b/gio/gnetworkaddress.c
index 342a6b9ba..0519713c5 100644
--- a/gio/gnetworkaddress.c
+++ b/gio/gnetworkaddress.c
@@ -453,7 +453,7 @@ _g_uri_parse_authority (const char *uri,
char **userinfo)
{
char *tmp_str;
- const char *start, *p;
+ const char *start, *p, *at, *delim;
char c;
g_return_val_if_fail (uri != NULL, FALSE);
@@ -493,7 +493,14 @@ _g_uri_parse_authority (const char *uri,
start += 2;
- if (strchr (start, '@') != NULL)
+ /* check if the @ sign is part of the authority before attempting to
+ * decode the userinfo */
+ delim = strpbrk (start, "/?#[]");
+ at = strchr (start, '@');
+ if (at && delim && at > delim)
+ at = NULL;
+
+ if (at != NULL)
{
/* Decode userinfo:
* userinfo = *( unreserved / pct-encoded / sub-delims / ":" )