From d350aedcf06ae86de7b615e963d39cb699723230 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 20 Oct 2011 17:27:34 -0400 Subject: SoupAuthBasic: allow (some) non-ASCII usernames/passwords MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- libsoup/soup-logger.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'libsoup/soup-logger.c') 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, ':'); -- cgit v1.2.1