mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
uri: do not encode userinfo fields
g_uri_build_with_user() builds a userinfo, but it shouldn't encode it itself, but let the user flags declare what's there. Otherwise, to_string() code paths may encode a second time. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
a97fe4e863
commit
b0f9af0e1d
20
glib/guri.c
20
glib/guri.c
@ -1634,33 +1634,19 @@ g_uri_build_with_user (GUriFlags flags,
|
||||
|
||||
if (user)
|
||||
{
|
||||
userinfo = g_string_new (NULL);
|
||||
if (flags & G_URI_FLAGS_ENCODED)
|
||||
g_string_append (userinfo, uri->user);
|
||||
else
|
||||
g_string_append_uri_escaped (userinfo, uri->user, USER_ALLOWED_CHARS, TRUE);
|
||||
userinfo = g_string_new (user);
|
||||
if (password)
|
||||
{
|
||||
g_string_append_c (userinfo, ':');
|
||||
if (flags & G_URI_FLAGS_ENCODED)
|
||||
g_string_append (userinfo, uri->password);
|
||||
else
|
||||
g_string_append_uri_escaped (userinfo, uri->password,
|
||||
PASSWORD_ALLOWED_CHARS, TRUE);
|
||||
g_string_append (userinfo, uri->password);
|
||||
}
|
||||
if (auth_params)
|
||||
{
|
||||
g_string_append_c (userinfo, ';');
|
||||
if (flags & G_URI_FLAGS_ENCODED)
|
||||
g_string_append (userinfo, uri->auth_params);
|
||||
else
|
||||
g_string_append_uri_escaped (userinfo,
|
||||
uri->auth_params, AUTH_PARAMS_ALLOWED_CHARS, TRUE);
|
||||
g_string_append (userinfo, uri->auth_params);
|
||||
}
|
||||
uri->userinfo = g_string_free (userinfo, FALSE);
|
||||
}
|
||||
else
|
||||
uri->userinfo = NULL;
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
@ -987,6 +987,12 @@ test_uri_build (void)
|
||||
g_assert_cmpstr (g_uri_get_auth_params (uri), ==, "authparams");
|
||||
g_uri_unref (uri);
|
||||
|
||||
uri = g_uri_build_with_user (G_URI_FLAGS_NONE, "scheme", "user\001", "password\002",
|
||||
"authparams\003", "host", 1234,
|
||||
"/path", "query", "fragment");
|
||||
g_assert_cmpstr (g_uri_get_userinfo (uri), ==, "user\001:password\002;authparams\003");
|
||||
g_uri_unref (uri);
|
||||
|
||||
uri = g_uri_build_with_user (G_URI_FLAGS_ENCODED, "scheme", "user%01", "password%02",
|
||||
"authparams%03", "host", 1234,
|
||||
"/path", "query", "fragment");
|
||||
|
Loading…
Reference in New Issue
Block a user