From e8ea75f1bd6f868a996f799b140ba8b6c8f5ebec Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 12 Jan 2007 04:51:04 +0000 Subject: fixed stray quote character appearing after encoding mail headers. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1470 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 6 ++++++ ChangeLog.ja | 7 +++++++ libsylph/codeconv.c | 21 ++++++++++++++------- libsylph/utils.c | 23 ++++++++++++++++++----- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b1fa88a..dbb8ad7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-01-12 + + * libsylph/utils.c + libsylph/codeconv.c: conv_encode_header(): handle quote correctly + (fixes stray quote character appearing after encoding mail headers). + 2007-01-11 * libsylph/procmime.c: procmime_parse_mime_parameter(): allow spaces diff --git a/ChangeLog.ja b/ChangeLog.ja index d2e3d3f2..a4b1ffb0 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,3 +1,10 @@ +2007-01-12 + + * libsylph/utils.c + libsylph/codeconv.c: conv_encode_header(): 引用符を正しく処理する + ようにした(メールヘッダのエンコード後に単独の引用符が現れるのを + 修正)。 + 2007-01-11 * libsylph/procmime.c: procmime_parse_mime_parameter(): MIME diff --git a/libsylph/codeconv.c b/libsylph/codeconv.c index 6a16513c..605849d9 100644 --- a/libsylph/codeconv.c +++ b/libsylph/codeconv.c @@ -2175,6 +2175,8 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src, left = MAX_LINELEN - header_len; while (*srcp) { + gboolean in_quote = FALSE; + LBREAK_IF_REQUIRED(left <= 0, TRUE); while (g_ascii_isspace(*srcp)) { @@ -2219,13 +2221,18 @@ void conv_encode_header(gchar *dest, gint len, const gchar *src, gboolean cont = FALSE; while (*p != '\0') { - if (g_ascii_isspace(*p) && - !is_next_nonascii(p + 1)) - break; - /* don't include parentheses in encoded - strings */ - if (addr_field && (*p == '(' || *p == ')')) - break; + if (*p == '"') + in_quote ^= TRUE; + else if (!in_quote) { + if (g_ascii_isspace(*p) && + !is_next_nonascii(p + 1)) + break; + /* don't include parentheses in encoded + strings */ + if (addr_field && + (*p == '(' || *p == ')')) + break; + } mb_len = g_utf8_skip[*(guchar *)p]; diff --git a/libsylph/utils.c b/libsylph/utils.c index 663d121f..f8f5d005 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -468,13 +468,19 @@ gint str_find_format_times(const gchar *haystack, gchar ch) gboolean is_next_nonascii(const gchar *s) { const gchar *p; + gboolean in_quote = FALSE; /* skip head space */ for (p = s; *p != '\0' && g_ascii_isspace(*p); p++) ; - for (; *p != '\0' && !g_ascii_isspace(*p); p++) { - if (*(guchar *)p > 127 || *(guchar *)p < 32) + while (*p != '\0') { + if (!in_quote && g_ascii_isspace(*p)) + break; + if (*p == '"') + in_quote ^= TRUE; + else if (*(guchar *)p > 127 || *(guchar *)p < 32) return TRUE; + ++p; } return FALSE; @@ -482,12 +488,19 @@ gboolean is_next_nonascii(const gchar *s) gint get_next_word_len(const gchar *s) { + const gchar *p = s; gint len = 0; + gboolean in_quote = FALSE; - for (; *s != '\0' && !g_ascii_isspace(*s); s++, len++) - ; + while (*p != '\0') { + if (!in_quote && g_ascii_isspace(*p)) + break; + if (*p == '"') + in_quote ^= TRUE; + ++p; + } - return len; + return p - s; } /* compare subjects */ -- cgit v1.2.3