evolution-data-server r9819 - branches/gnome-2-24/camel/providers/pop3
- From: mcrha svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9819 - branches/gnome-2-24/camel/providers/pop3
- Date: Tue, 9 Dec 2008 16:52:09 +0000 (UTC)
Author: mcrha
Date: Tue Dec 9 16:52:08 2008
New Revision: 9819
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9819&view=rev
Log:
2008-12-09 Milan Crha <mcrha redhat com>
** Fix for bug #552986
* camel-pop3-store.c: (ensure_utf8), (pop3_connect):
Ensure error description is valid UTF-8 text before using it.
Modified:
branches/gnome-2-24/camel/providers/pop3/ChangeLog
branches/gnome-2-24/camel/providers/pop3/camel-pop3-store.c
Modified: branches/gnome-2-24/camel/providers/pop3/camel-pop3-store.c
==============================================================================
--- branches/gnome-2-24/camel/providers/pop3/camel-pop3-store.c (original)
+++ branches/gnome-2-24/camel/providers/pop3/camel-pop3-store.c Tue Dec 9 16:52:08 2008
@@ -573,6 +573,25 @@
return status;
}
+/* ensures the returned text will be valid UTF-8 text, thus gtk functions expecting
+ only valid UTF-8 texts will not crash. Returned pointer should be freed with g_free. */
+static gchar *
+ensure_utf8 (const char *text)
+{
+ gchar *res = g_strdup (text), *p;
+
+ if (!text)
+ return res;
+
+ p = res;
+ while (!g_utf8_validate (p, -1, (const gchar **) &p)) {
+ /* make all invalid characters appear as question marks */
+ *p = '?';
+ }
+
+ return res;
+}
+
static gboolean
pop3_connect (CamelService *service, CamelException *ex)
{
@@ -609,7 +628,9 @@
/* we only re-prompt if we failed to authenticate, any other error and we just abort */
if (status == 0 && camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE) {
- errbuf = g_markup_printf_escaped ("%s\n\n", camel_exception_get_description (ex));
+ char *tmp = ensure_utf8 (camel_exception_get_description (ex));
+ errbuf = g_markup_printf_escaped ("%s\n\n", tmp);
+ g_free (tmp);
camel_exception_clear (ex);
camel_session_forget_password (session, service, NULL, "password", ex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]