evolution-data-server r9818 - in trunk/camel: . providers/pop3
- From: mcrha svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9818 - in trunk/camel: . providers/pop3
- Date: Tue, 9 Dec 2008 16:44:48 +0000 (UTC)
Author: mcrha
Date: Tue Dec 9 16:44:48 2008
New Revision: 9818
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9818&view=rev
Log:
2008-12-09 Milan Crha <mcrha redhat com>
** Fix for bug #552986
* camel/camel-utf8.h: (camel_utf8_make_valid):
* camel/camel-utf8.c: (camel_utf8_make_valid): New utility function.
* camel/providers/pop3/camel-pop3-store.c: (pop3_connect):
Ensure error description is valid UTF-8 text before using it.
Modified:
trunk/camel/ChangeLog
trunk/camel/camel-utf8.c
trunk/camel/camel-utf8.h
trunk/camel/providers/pop3/ChangeLog
trunk/camel/providers/pop3/camel-pop3-store.c
Modified: trunk/camel/camel-utf8.c
==============================================================================
--- trunk/camel/camel-utf8.c (original)
+++ trunk/camel/camel-utf8.c Tue Dec 9 16:44:48 2008
@@ -399,3 +399,27 @@
return out;
}
+
+/**
+ * camel_utf8_make_valid:
+ * @text:
+ *
+ * Ensures the returned text will be valid UTF-8 string, with incorrect letters
+ * changed to question marks. Returned pointer should be freed with g_free.
+ **/
+char *
+camel_utf8_make_valid (const char *text)
+{
+ gchar *res = g_strdup (text), *p;
+
+ if (!res)
+ return res;
+
+ p = res;
+ while (!g_utf8_validate (p, -1, (const gchar **) &p)) {
+ /* make all invalid characters appear as question marks */
+ *p = '?';
+ }
+
+ return res;
+}
Modified: trunk/camel/camel-utf8.h
==============================================================================
--- trunk/camel/camel-utf8.h (original)
+++ trunk/camel/camel-utf8.h Tue Dec 9 16:44:48 2008
@@ -40,6 +40,9 @@
char *camel_utf8_ucs2(const char *ptr);
char *camel_ucs2_utf8(const char *ptr);
+/* make valid utf8 string */
+char *camel_utf8_make_valid (const char *text);
+
G_END_DECLS
#endif /* ! _CAMEL_UTF8_H */
Modified: trunk/camel/providers/pop3/camel-pop3-store.c
==============================================================================
--- trunk/camel/providers/pop3/camel-pop3-store.c (original)
+++ trunk/camel/providers/pop3/camel-pop3-store.c Tue Dec 9 16:44:48 2008
@@ -50,6 +50,7 @@
#include "camel-tcp-stream-raw.h"
#include "camel-tcp-stream.h"
#include "camel-url.h"
+#include "camel-utf8.h"
#ifdef HAVE_SSL
#include "camel-tcp-stream-ssl.h"
@@ -610,7 +611,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 = camel_utf8_make_valid (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]