diff options
| author | Sivaiah Nallagatla <snallagatla@novell.com> | 2005-02-14 19:24:41 +0000 |
|---|---|---|
| committer | Sivaiah Nallagatla <siva@src.gnome.org> | 2005-02-14 19:24:41 +0000 |
| commit | 251ca51dc148f3ffbcf2f2d7e0e19912c2f25c2a (patch) | |
| tree | c68ae9d809ae14e9f427030ef97a74dfc1d42d1f | |
| parent | dfe2514683cbe6d2b4e5ba527e60be981c227098 (diff) | |
| download | evolution-data-server-251ca51dc148f3ffbcf2f2d7e0e19912c2f25c2a.tar.gz | |
Make sure that we decode only hex digits followed by '=' while decoding
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
Fixes an issue related to data loss in 1.4 -> 2.0
migration
| -rw-r--r-- | addressbook/ChangeLog | 16 | ||||
| -rw-r--r-- | addressbook/libebook/e-vcard.c | 29 |
2 files changed, 36 insertions, 9 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 9069606c0..211fa4159 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,19 @@ +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 + + Fixes an issue related to data loss in 1.4 -> 2.0 + migration + 2005-02-10 Sivaiah Nallagatla <snallagatla@novell.com> * backends/ldap/e-book-backend-ldap.c diff --git a/addressbook/libebook/e-vcard.c b/addressbook/libebook/e-vcard.c index 0fb870cc1..382551a76 100644 --- a/addressbook/libebook/e-vcard.c +++ b/addressbook/libebook/e-vcard.c @@ -235,19 +235,23 @@ read_attribute_value (EVCardAttribute *attr, char **p, gboolean quoted_printable * 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); |
