[evolution-data-server/gnome-3-16] Bug 752338 - Incorrect handling of multibyte characters in vCards
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-16] Bug 752338 - Incorrect handling of multibyte characters in vCards
- Date: Wed, 5 Aug 2015 15:33:35 +0000 (UTC)
commit fdedff309c8cff629a8e1e10641a2d87a6e3ba41
Author: Alex Shtyrov <alex shtyrov collabora co uk>
Date: Wed Aug 5 17:30:57 2015 +0200
Bug 752338 - Incorrect handling of multibyte characters in vCards
addressbook/libebook-contacts/e-vcard.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/addressbook/libebook-contacts/e-vcard.c b/addressbook/libebook-contacts/e-vcard.c
index e5c611b..9ff2298 100644
--- a/addressbook/libebook-contacts/e-vcard.c
+++ b/addressbook/libebook-contacts/e-vcard.c
@@ -334,30 +334,37 @@ read_attribute_value (EVCardAttribute *attr,
lp = skip_newline ( lp, quoted_printable ) ) {
if (*lp == '=' && quoted_printable) {
- gchar a, b;
+ gunichar a, b;
/* it's for the '=' */
lp++;
lp = skip_newline (lp, quoted_printable);
- if ((a = *(lp++)) == '\0') break;
+ a = g_utf8_get_char (lp);
+ lp = g_utf8_next_char (lp);
+ if (a == '\0')
+ break;
+
lp = skip_newline (lp, quoted_printable);
- if ((b = *(lp++)) == '\0') break;
- if (isxdigit (a) && isxdigit (b)) {
+ b = g_utf8_get_char (lp);
+ if (b == '\0')
+ break;
+ lp = g_utf8_next_char (lp);
+
+ if (g_unichar_isxdigit (a) && g_unichar_isxdigit (b)) {
gchar c;
- a = tolower (a);
- b = tolower (b);
+ gint a_bin = g_unichar_xdigit_value (a);
+ gint b_bin = g_unichar_xdigit_value (b);
- c = (((a >= 'a' ? a - 'a' + 10 : a - '0') & 0x0f) << 4)
- | ((b >= 'a' ? b - 'a' + 10 : b - '0') & 0x0f);
+ c = (a_bin << 4) | b_bin;
g_string_append_c (str, c); /* add decoded byte (this is not a unicode yet) */
} else {
g_string_append_c (str, '=');
- g_string_append_c (str, a);
- g_string_append_c (str, b);
+ g_string_append_unichar (str, a);
+ g_string_append_unichar (str, b);
}
} else if (*lp == '\\') {
/* convert back to the non-escaped version of
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]