mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 14:36:16 +01:00
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
This commit is contained in:
parent
8d037c678d
commit
20feb23569
@ -453,7 +453,7 @@ _g_uri_parse_authority (const char *uri,
|
|||||||
char **userinfo)
|
char **userinfo)
|
||||||
{
|
{
|
||||||
char *tmp_str;
|
char *tmp_str;
|
||||||
const char *start, *p;
|
const char *start, *p, *at, *delim;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
g_return_val_if_fail (uri != NULL, FALSE);
|
g_return_val_if_fail (uri != NULL, FALSE);
|
||||||
@ -493,7 +493,14 @@ _g_uri_parse_authority (const char *uri,
|
|||||||
|
|
||||||
start += 2;
|
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:
|
/* Decode userinfo:
|
||||||
* userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
|
* userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
|
||||||
|
@ -42,7 +42,8 @@ static ParseTest uri_tests[] = {
|
|||||||
{ "http://[fec0::abcd%em1]/start", "http", "fec0::abcd%em1", 8080, -1 },
|
{ "http://[fec0::abcd%em1]/start", "http", "fec0::abcd%em1", 8080, -1 },
|
||||||
{ "http://[fec0::abcd%25em1]/start", "http", "fec0::abcd%em1", 8080, -1 },
|
{ "http://[fec0::abcd%25em1]/start", "http", "fec0::abcd%em1", 8080, -1 },
|
||||||
{ "http://[fec0::abcd%10]/start", "http", "fec0::abcd%10", 8080, -1 },
|
{ "http://[fec0::abcd%10]/start", "http", "fec0::abcd%10", 8080, -1 },
|
||||||
{ "http://[fec0::abcd%25em%31]/start", NULL, NULL, 0, G_IO_ERROR_INVALID_ARGUMENT }
|
{ "http://[fec0::abcd%25em%31]/start", NULL, NULL, 0, G_IO_ERROR_INVALID_ARGUMENT },
|
||||||
|
{ "ftp://ftp.gnome.org/start?foo=bar@baz", "ftp", "ftp.gnome.org", 8080, -1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user