summaryrefslogtreecommitdiff
path: root/libsoup/soup-logger.c
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2011-10-20 17:27:34 -0400
committerDan Winship <danw@gnome.org>2011-11-13 15:11:57 -0500
commitd350aedcf06ae86de7b615e963d39cb699723230 (patch)
tree2f18c732e17e0915ed873c7594a705e8d6506a29 /libsoup/soup-logger.c
parentee85d6448a90cc0e4072414ca69e85078b1fc0f7 (diff)
downloadlibsoup-d350aedcf06ae86de7b615e963d39cb699723230.tar.gz
SoupAuthBasic: allow (some) non-ASCII usernames/passwords
Convert the (assumed-UTF-8) username and password into ISO-8859-1 before encoding. This is what a few other browsers do. Based on a patch from Joachim Breitner, sponsored by ITOMIG GmbH and the City of Böblingen. https://bugzilla.gnome.org/show_bug.cgi?id=576838
Diffstat (limited to 'libsoup/soup-logger.c')
-rw-r--r--libsoup/soup-logger.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/libsoup/soup-logger.c b/libsoup/soup-logger.c
index ac901fc4..b159e678 100644
--- a/libsoup/soup-logger.c
+++ b/libsoup/soup-logger.c
@@ -422,10 +422,21 @@ soup_logger_print (SoupLogger *logger, SoupLoggerLogLevel level,
static void
soup_logger_print_basic_auth (SoupLogger *logger, const char *value)
{
- char *decoded, *p;
+ char *decoded, *decoded_utf8, *p;
gsize len;
decoded = (char *)g_base64_decode (value + 6, &len);
+ if (decoded && !g_utf8_validate (decoded, -1, NULL)) {
+ decoded_utf8 = g_convert_with_fallback (decoded, -1,
+ "UTF-8", "ISO-8859-1",
+ NULL, NULL, &len,
+ NULL);
+ if (decoded_utf8) {
+ g_free (decoded);
+ decoded = decoded_utf8;
+ }
+ }
+
if (!decoded)
decoded = g_strdup (value);
p = strchr (decoded, ':');