diff options
| author | Milan Crha <mcrha@redhat.com> | 2008-11-19 15:14:42 +0000 |
|---|---|---|
| committer | Milan Crha <mcrha@src.gnome.org> | 2008-11-19 15:14:42 +0000 |
| commit | c2dc077a753407ad975387eaec9bf88bcece8891 (patch) | |
| tree | a14b3d752f02b7a122fee61172d5f28777f878e6 | |
| parent | b77d641cc24313f174a50eb72a27ba2b0a83fce0 (diff) | |
| download | evolution-data-server-c2dc077a753407ad975387eaec9bf88bcece8891.tar.gz | |
** Fix for bug #560681
2008-11-19 Milan Crha <mcrha@redhat.com>
** Fix for bug #560681
* libebook/e-vcard.c: (read_attribute_value), (read_attribute_params),
(read_attribute): Support CHARSET parameter within the attribute and
convert text to UTF-8, if necessary, based on its value.
svn path=/trunk/; revision=9774
| -rw-r--r-- | addressbook/ChangeLog | 8 | ||||
| -rw-r--r-- | addressbook/libebook/e-vcard.c | 38 |
2 files changed, 42 insertions, 4 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 5341b1a59..073189231 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,11 @@ +2008-11-19 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #560681 + + * libebook/e-vcard.c: (read_attribute_value), (read_attribute_params), + (read_attribute): Support CHARSET parameter within the attribute and + convert text to UTF-8, if necessary, based on its value. + 2008-11-07 Sankar P <psankar@novell.com> ** Patch committed on behalf of Ashish Shrivastava <shashish@novell.com> diff --git a/addressbook/libebook/e-vcard.c b/addressbook/libebook/e-vcard.c index 25abb4d95..f0b24e8b9 100644 --- a/addressbook/libebook/e-vcard.c +++ b/addressbook/libebook/e-vcard.c @@ -223,7 +223,7 @@ skip_until (char **p, char *s) } static void -read_attribute_value (EVCardAttribute *attr, char **p, gboolean quoted_printable) +read_attribute_value (EVCardAttribute *attr, char **p, gboolean quoted_printable, const char *charset) { char *lp = *p; GString *str; @@ -289,6 +289,16 @@ read_attribute_value (EVCardAttribute *attr, char **p, gboolean quoted_printable } else if ((*lp == ';') || (*lp == ',' && !g_ascii_strcasecmp (attr->name, "CATEGORIES"))) { + if (charset) { + char *tmp; + + tmp = g_convert (str->str, str->len, "UTF-8", charset, NULL, NULL, NULL); + if (tmp) { + g_string_assign (str, tmp); + g_free (tmp); + } + } + e_vcard_attribute_add_value (attr, str->str); g_string_assign (str, ""); lp = g_utf8_next_char(lp); @@ -299,6 +309,16 @@ read_attribute_value (EVCardAttribute *attr, char **p, gboolean quoted_printable } } if (str) { + if (charset) { + char *tmp; + + tmp = g_convert (str->str, str->len, "UTF-8", charset, NULL, NULL, NULL); + if (tmp) { + g_string_assign (str, tmp); + g_free (tmp); + } + } + e_vcard_attribute_add_value (attr, str->str); g_string_free (str, TRUE); } @@ -309,7 +329,7 @@ read_attribute_value (EVCardAttribute *attr, char **p, gboolean quoted_printable } static void -read_attribute_params (EVCardAttribute *attr, char **p, gboolean *quoted_printable) +read_attribute_params (EVCardAttribute *attr, char **p, gboolean *quoted_printable, char **charset) { char *lp; GString *str; @@ -389,6 +409,13 @@ read_attribute_params (EVCardAttribute *attr, char **p, gboolean *quoted_printab *quoted_printable = TRUE; e_vcard_attribute_param_free (param); param = NULL; + } else if (param + && !g_ascii_strcasecmp (param->name, "charset") + && g_ascii_strcasecmp (param->values->data, "utf-8") != 0) { + g_free (*charset); + *charset = g_strdup (param->values->data); + e_vcard_attribute_param_free (param); + param = NULL; } } else { @@ -468,6 +495,7 @@ read_attribute (char **p) GString *str; char *lp; gboolean is_qp = FALSE; + char *charset = NULL; /* first read in the group/name */ str = g_string_new (""); @@ -533,16 +561,18 @@ read_attribute (char **p) if (*lp == ';') { /* skip past the ';' */ lp = g_utf8_next_char(lp); - read_attribute_params (attr, &lp, &is_qp); + read_attribute_params (attr, &lp, &is_qp, &charset); if (is_qp) attr->encoding = EVC_ENCODING_RAW; } if (*lp == ':') { /* skip past the ':' */ lp = g_utf8_next_char(lp); - read_attribute_value (attr, &lp, is_qp); + read_attribute_value (attr, &lp, is_qp, charset); } + g_free (charset); + *p = lp; if (!attr->values) |
