[evolution-patches] patch for e-vcard.c (address book)
- From: Sivaiah Nallagatla <snallagatla novell com>
- To: evolution-patches <evolution-patches ximian com>
- Subject: [evolution-patches] patch for e-vcard.c (address book)
- Date: Mon, 14 Feb 2005 16:42:01 +0530
Atached patch solves the issue of losing data during 1.4 to 2.0 contact
migration in some cases. The addresses and notes were encoded using
quoted-printable encoding in 1.4. There were some issues in decoding
that value during in v-card parsing in 2.0, so the when the vcard is
written as string (e_vcard_string), it resulted invlaid utf-8 string
causing the loss of data during migration. This issue is seen when the
notes and addresses in 1.4 contacth has non-ascci (chars with value >
127).
Siva
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/ChangeLog,v
retrieving revision 1.247
diff -u -p -r1.247 ChangeLog
--- ChangeLog 7 Feb 2005 18:33:36 -0000 1.247
+++ ChangeLog 14 Feb 2005 11:17:41 -0000
@@ -1,3 +1,16 @@
+2005-02-14 Sivaiah Nallagatla <snallagatla novell com>
+
+ * libebook/e-vcard.c (read_attribute_value) :
+ Make sure that we decode only hex digits followed
+ by '=' while decoding from quoted printable encoding.
+ (read_attribute) : Reset the encoding as RAW for values
+ which are encoded in Quoated printable encoding in the
+ original vcard. We are not going encodwe them again
+ using quoated printable
+ (e_vcard_to_string_vcard_30) : use utf-8 version
+ of strlen and other functions while folding lines
+ as some the chars may be represented by more than one byte
+
2005-02-06 Sivaiah Nallagatla <snallagatla novell com>
* libebook/e-contact.h : place the E_CONTACT_REV
Index: libebook/e-vcard.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-vcard.c,v
retrieving revision 1.17
diff -u -p -r1.17 e-vcard.c
--- libebook/e-vcard.c 31 Jan 2005 06:47:40 -0000 1.17
+++ libebook/e-vcard.c 14 Feb 2005 11:17:42 -0000
@@ -235,19 +235,23 @@ read_attribute_value (EVCardAttribute *a
* 2 kinds of line folding
*/
}
- else if (isalnum(a) && isalnum (b)) {
- char c;
+ else if (isxdigit(a) && isxdigit (b)) {
+ gunichar c;
a = tolower (a);
b = tolower (b);
c = (((a>='a'?a-'a'+10:a-'0')&0x0f) << 4)
| ((b>='a'?b-'a'+10:b-'0')&0x0f);
-
- str = g_string_append_c (str, c);
+
+ str = g_string_append_unichar (str, c);
}
- /* silently consume malformed input, and
- continue parsing */
+ else
+ {
+ str = g_string_append_c (str, a);
+ str = g_string_append_c (str, b);
+ }
+
lp++;
}
else if (*lp == '\\') {
@@ -516,6 +520,8 @@ read_attribute (char **p)
/* skip past the ';' */
lp = g_utf8_next_char(lp);
read_attribute_params (attr, &lp, &is_qp);
+ if (is_qp)
+ attr->encoding = EVC_ENCODING_RAW;
}
if (*lp == ':') {
/* skip past the ':' */
@@ -798,13 +804,18 @@ e_vcard_to_string_vcard_30 (EVCard *evc)
*/
l = 0;
do {
- if (attr_str->len - l > 75) {
+
+ if ((g_utf8_strlen (attr_str->str, -1) -l) > 75) {
+ char *p;
+
l += 75;
- attr_str = g_string_insert_len (attr_str, l, CRLF " ", sizeof (CRLF " ") - 1);
+ p = g_utf8_offset_to_pointer (attr_str->str, l);
+
+ attr_str = g_string_insert_len (attr_str, (p - attr_str->str), CRLF " ", sizeof (CRLF " ") - 1);
}
else
break;
- } while (l < attr_str->len);
+ } while (l < g_utf8_strlen (attr_str->str, -1));
attr_str = g_string_append (attr_str, CRLF);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]