diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2007-05-16 05:42:21 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2007-05-16 05:42:21 +0000 |
commit | e7e717c4ee877a009657e2f971a5c188daf55701 (patch) | |
tree | 197affe3ea00b7460b09f4141148ca5d5805bc7a /libsylph | |
parent | c5575f297c9e68bb0eaad671b4afb25ebe441186 (diff) |
process quoted-pair correctly.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1694 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/procheader.c | 4 | ||||
-rw-r--r-- | libsylph/utils.c | 50 | ||||
-rw-r--r-- | libsylph/utils.h | 5 |
3 files changed, 57 insertions, 2 deletions
diff --git a/libsylph/procheader.c b/libsylph/procheader.c index 4d45dbe7..2c931e07 100644 --- a/libsylph/procheader.c +++ b/libsylph/procheader.c @@ -752,7 +752,7 @@ gchar *procheader_get_fromname(const gchar *str) Xstrdup_a(tmp, str, return NULL); if (*tmp == '\"') { - extract_quote(tmp, '\"'); + extract_quote_with_escape(tmp, '\"'); g_strstrip(tmp); } else if (strchr(tmp, '<')) { eliminate_parenthesis(tmp, '<', '>'); @@ -763,7 +763,7 @@ gchar *procheader_get_fromname(const gchar *str) g_strstrip(tmp); } } else if (strchr(tmp, '(')) { - extract_parenthesis(tmp, '(', ')'); + extract_parenthesis_with_escape(tmp, '(', ')'); g_strstrip(tmp); } diff --git a/libsylph/utils.c b/libsylph/utils.c index 1336d954..56e7fccd 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -652,6 +652,37 @@ void extract_parenthesis(gchar *str, gchar op, gchar cl) *destp = '\0'; } +void extract_parenthesis_with_escape(gchar *str, gchar op, gchar cl) +{ + register gchar *srcp, *destp; + gint in_brace; + + srcp = destp = str; + + while ((srcp = strchr(srcp, op))) { + if (destp > str) + *destp++ = ' '; + ++srcp; + //memmove(destp, srcp + 1, strlen(srcp)); + in_brace = 1; + while (*srcp) { + if (*srcp == op) + in_brace++; + else if (*srcp == cl) + in_brace--; + + if (in_brace == 0) + break; + + if (*srcp == '\\' && *(srcp + 1) != '\0') + ++srcp; + + *destp++ = *srcp++; + } + } + *destp = '\0'; +} + void extract_parenthesis_with_skip_quote(gchar *str, gchar quote_chr, gchar op, gchar cl) { @@ -713,6 +744,25 @@ void extract_quote(gchar *str, gchar quote_chr) } } +void extract_quote_with_escape(gchar *str, gchar quote_chr) +{ + register gchar *sp, *dp; + + if ((sp = strchr(str, quote_chr))) { + dp = sp; + ++sp; + while (*sp) { + if (*sp == quote_chr) + break; + else if (*sp == '\\' && *(sp + 1) != '\0') + ++sp; + + *dp++ = *sp++; + } + *dp = '\0'; + } +} + void eliminate_address_comment(gchar *str) { register gchar *srcp, *destp; diff --git a/libsylph/utils.h b/libsylph/utils.h index fe0b585b..d7f68b91 100644 --- a/libsylph/utils.h +++ b/libsylph/utils.h @@ -257,6 +257,9 @@ void eliminate_parenthesis (gchar *str, void extract_parenthesis (gchar *str, gchar op, gchar cl); +void extract_parenthesis_with_escape (gchar *str, + gchar op, + gchar cl); void extract_parenthesis_with_skip_quote (gchar *str, gchar quote_chr, @@ -267,6 +270,8 @@ void eliminate_quote (gchar *str, gchar quote_chr); void extract_quote (gchar *str, gchar quote_chr); +void extract_quote_with_escape (gchar *str, + gchar quote_chr); void eliminate_address_comment (gchar *str); gchar *strchr_with_skip_quote (const gchar *str, gint quote_chr, |