mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
uri: do not encode ':' and ';' from userinfo
The g_uri_join_internal() function was making a simplification that userinfo can be encoded with the same restricted character set as the user field alone, fix this by allowing the correct character set. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
c354c404c6
commit
ef173e2e75
18
glib/guri.c
18
glib/guri.c
@ -1328,6 +1328,7 @@ g_uri_resolve_relative (const gchar *base_uri_string,
|
||||
static gchar *
|
||||
g_uri_join_internal (GUriFlags flags,
|
||||
const gchar *scheme,
|
||||
gboolean userinfo,
|
||||
const gchar *user,
|
||||
const gchar *password,
|
||||
const gchar *auth_params,
|
||||
@ -1353,11 +1354,14 @@ g_uri_join_internal (GUriFlags flags,
|
||||
g_string_append (str, user);
|
||||
else
|
||||
{
|
||||
/* Encode ':' and ';' regardless of whether we have a
|
||||
* password or auth params, since it may be parsed later
|
||||
* under the assumption that it does.
|
||||
*/
|
||||
g_string_append_uri_escaped (str, user, USER_ALLOWED_CHARS, TRUE);
|
||||
if (userinfo)
|
||||
g_string_append_uri_escaped (str, user, USERINFO_ALLOWED_CHARS, TRUE);
|
||||
else
|
||||
/* Encode ':' and ';' regardless of whether we have a
|
||||
* password or auth params, since it may be parsed later
|
||||
* under the assumption that it does.
|
||||
*/
|
||||
g_string_append_uri_escaped (str, user, USER_ALLOWED_CHARS, TRUE);
|
||||
}
|
||||
|
||||
if (password)
|
||||
@ -1467,7 +1471,7 @@ g_uri_join (GUriFlags flags,
|
||||
|
||||
return g_uri_join_internal (flags,
|
||||
scheme,
|
||||
userinfo, NULL, NULL,
|
||||
TRUE, userinfo, NULL, NULL,
|
||||
host,
|
||||
port,
|
||||
path,
|
||||
@ -1519,7 +1523,7 @@ g_uri_join_with_user (GUriFlags flags,
|
||||
|
||||
return g_uri_join_internal (flags,
|
||||
scheme,
|
||||
user, password, auth_params,
|
||||
FALSE, user, password, auth_params,
|
||||
host,
|
||||
port,
|
||||
path,
|
||||
|
@ -1403,6 +1403,10 @@ test_uri_join (void)
|
||||
{
|
||||
gchar *uri = NULL;
|
||||
|
||||
uri = g_uri_join (G_URI_FLAGS_NONE, "foo", "some:user@info", "bar", -1, "", NULL, NULL);
|
||||
g_assert_cmpstr (uri, ==, "foo://some:user%40info@bar");
|
||||
g_free (uri);
|
||||
|
||||
uri = g_uri_join_with_user (G_URI_FLAGS_NONE, "scheme", "user\001", "pass\002", "authparams\003",
|
||||
"host", 9876, "/path", "query", "fragment");
|
||||
g_assert_cmpstr (uri, ==, "scheme://user%01:pass%02;authparams%03@host:9876/path?query#fragment");
|
||||
|
Loading…
Reference in New Issue
Block a user