aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjohans <johans@FreeBSD.org>2006-09-21 21:52:51 +0800
committerjohans <johans@FreeBSD.org>2006-09-21 21:52:51 +0800
commit8e0891df730163ff905c545c96063330880c3068 (patch)
tree4e30f46d5516ae6ee84ed8b7514687c615897c50
parent25310bdb1e055fab7296f6d1812fe5cb10b948a3 (diff)
downloadfreebsd-ports-gnome-8e0891df730163ff905c545c96063330880c3068.tar.gz
freebsd-ports-gnome-8e0891df730163ff905c545c96063330880c3068.tar.zst
freebsd-ports-gnome-8e0891df730163ff905c545c96063330880c3068.zip
- Fix foreign charset decoding in headers
- Fix handing of Big5 characters PR: ports/103082 Submitted by: wchunhao@csie.nctu.edu.tw
-rw-r--r--mail/elm+ME/files/patch-hdrdecode.c84
-rw-r--r--mail/elm+ME/files/patch-precompiled_sets.c12
2 files changed, 96 insertions, 0 deletions
diff --git a/mail/elm+ME/files/patch-hdrdecode.c b/mail/elm+ME/files/patch-hdrdecode.c
new file mode 100644
index 000000000000..730250394dab
--- /dev/null
+++ b/mail/elm+ME/files/patch-hdrdecode.c
@@ -0,0 +1,84 @@
+--- lib/hdrdecode.c Sat Jul 9 18:03:15 2005
++++ lib/hdrdecode.c Sun Sep 10 04:57:10 2006
+@@ -173,9 +173,16 @@
+ char *encoded = NULL;
+ struct string *ret = NULL;
+ charset_t set;
++ char *front, *end;
++ struct string *fstr, *estr;
+
+- if ('=' != *p++)
++ /* Pasear: front, end are used to solve buffer: abc""=?...?=" problem */
++ front = p;
++ while (*p && '=' != *p) ++p;
++ if (front != p && '=' == *p && '"' == *(p-1)) *(p-1) = '\0';
++ if ('=' != *p)
+ goto fail;
++ *p = '\0'; ++p;
+ if ('?' != *p++)
+ goto fail;
+ sn = p;
+@@ -209,8 +216,8 @@
+ p++;
+ if ('=' != *p++)
+ goto fail;
+- if (*p)
+- goto fail;
++ if ('"' == *p) ++p;
++ end = p;
+
+ set = MIME_name_to_charset(sn,CHARSET_create);
+
+@@ -225,6 +232,18 @@
+ break;
+ }
+
++ /* Pasear */
++ if (ret){
++ estr = ret;
++ fstr = new_string2(system_charset,us_str(front));
++ fstr = ret = cat_strings(fstr, ret, 0);
++ free_string(&estr);
++ estr = new_string2(system_charset,us_str(end));
++ ret = cat_strings(ret, estr, 0);
++ free_string(&estr);
++ free_string(&fstr);
++ }
++
+ fail:
+ if (!ret) {
+ DPRINT(Debug,20,(&Debug,
+@@ -341,20 +360,31 @@
+ struct string * ret = new_string(defcharset);
+ char **tokenized = rfc822_tokenize(buffer);
+ unsigned char * last_char = NULL;
+- int i;
++ int i, encoded;
++ char* p;
+
+ for (i = 0; tokenized[i]; i++) {
+
+ struct string * ok = NULL;
+ int nostore = 0;
+
++ /* Pasear: detect if it is a encoded string */
++ encoded = 0;
++ if ('"' == tokenized[i][0]){
++ p = tokenized[i];
++ while (*p && *p != '=') ++p;
++ if (*p && *p == '=' && *(p+1) && *(p+1) == '?' )
++ encoded = 1;
++ }
++
++
+ if ('(' == tokenized[i][0]) {
+ /* we need add last space */
+ if (last_char)
+ add_ascii_to_string(ret,last_char);
+ ok = hdr_comment(tokenized[i],defcharset,demime);
+ nostore = 1;
+- } else if ('"' == tokenized[i][0]) {
++ } else if (!encoded && '"' == tokenized[i][0]) {
+ /* we need add last space */
+ if (last_char)
+ add_ascii_to_string(ret,last_char);
diff --git a/mail/elm+ME/files/patch-precompiled_sets.c b/mail/elm+ME/files/patch-precompiled_sets.c
new file mode 100644
index 000000000000..eb4caebe2027
--- /dev/null
+++ b/mail/elm+ME/files/patch-precompiled_sets.c
@@ -0,0 +1,12 @@
+--- lib/precompiled_sets.c Sat Jul 9 18:03:15 2005
++++ lib/precompiled_sets.c Sun Sep 10 03:29:48 2006
+@@ -404,7 +404,8 @@
+ { CS_charset_magic, &cs_euc, &map_EUC_ascii, SET_valid, "GB2312", NULL,
+ &set_EUCCN, 2025, "GB2312-1980" }, /* ASCII + GB 2312-80 */
+
+- { CS_charset_magic, &cs_unknown, NULL, SET_valid, "Big5", NULL, NULL, 2026, NULL },
++ { CS_charset_magic, &cs_ascii, &map_latin1, SET_valid, "Big5", ASCII,
++ &(sets_iso_8859_X[1]), 2026, "Big5" },
+ { CS_charset_magic, &cs_ascii, NULL, SET_valid, "windows-1250", ASCII, NULL, 2250, NULL },
+ { CS_charset_magic, &cs_ascii, NULL, SET_valid, "windows-1253", ASCII, NULL, 2253, NULL },
+ { CS_charset_magic, &cs_ascii, NULL, SET_valid, "windows-1254", ASCII ,NULL, 2254, NULL },