mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56: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
@ -1328,6 +1328,7 @@ g_uri_resolve_relative (const gchar *base_uri_string,
|
|||||||
static gchar *
|
static gchar *
|
||||||
g_uri_join_internal (GUriFlags flags,
|
g_uri_join_internal (GUriFlags flags,
|
||||||
const gchar *scheme,
|
const gchar *scheme,
|
||||||
|
gboolean userinfo,
|
||||||
const gchar *user,
|
const gchar *user,
|
||||||
const gchar *password,
|
const gchar *password,
|
||||||
const gchar *auth_params,
|
const gchar *auth_params,
|
||||||
@ -1353,6 +1354,9 @@ g_uri_join_internal (GUriFlags flags,
|
|||||||
g_string_append (str, user);
|
g_string_append (str, user);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (userinfo)
|
||||||
|
g_string_append_uri_escaped (str, user, USERINFO_ALLOWED_CHARS, TRUE);
|
||||||
|
else
|
||||||
/* Encode ':' and ';' regardless of whether we have a
|
/* Encode ':' and ';' regardless of whether we have a
|
||||||
* password or auth params, since it may be parsed later
|
* password or auth params, since it may be parsed later
|
||||||
* under the assumption that it does.
|
* under the assumption that it does.
|
||||||
@ -1467,7 +1471,7 @@ g_uri_join (GUriFlags flags,
|
|||||||
|
|
||||||
return g_uri_join_internal (flags,
|
return g_uri_join_internal (flags,
|
||||||
scheme,
|
scheme,
|
||||||
userinfo, NULL, NULL,
|
TRUE, userinfo, NULL, NULL,
|
||||||
host,
|
host,
|
||||||
port,
|
port,
|
||||||
path,
|
path,
|
||||||
@ -1519,7 +1523,7 @@ g_uri_join_with_user (GUriFlags flags,
|
|||||||
|
|
||||||
return g_uri_join_internal (flags,
|
return g_uri_join_internal (flags,
|
||||||
scheme,
|
scheme,
|
||||||
user, password, auth_params,
|
FALSE, user, password, auth_params,
|
||||||
host,
|
host,
|
||||||
port,
|
port,
|
||||||
path,
|
path,
|
||||||
|
@ -1403,6 +1403,10 @@ test_uri_join (void)
|
|||||||
{
|
{
|
||||||
gchar *uri = NULL;
|
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",
|
uri = g_uri_join_with_user (G_URI_FLAGS_NONE, "scheme", "user\001", "pass\002", "authparams\003",
|
||||||
"host", 9876, "/path", "query", "fragment");
|
"host", 9876, "/path", "query", "fragment");
|
||||||
g_assert_cmpstr (uri, ==, "scheme://user%01:pass%02;authparams%03@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