From: akr Date: Sat, 18 Jul 1998 20:34:12 +0000 (+0000) Subject: * (TESTPAT): add test. X-Git-Tag: flam-1_9_0~1 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01f40c819eae909ffc579cfdbfe7f2b3bda10acc;p=elisp%2Fflim.git * (TESTPAT): add test. * eword-decode.el (eword-analyze-quoted-string): quote string as quoted-string. (eword-analyze-encoded-word): quote non-atoms string as quoted-string. --- diff --git a/ChangeLog b/ChangeLog index bb3e050..059c0f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 1998-07-18 Tanaka Akira + * (TESTPAT): add test. + + * eword-decode.el (eword-analyze-quoted-string): quote string as + quoted-string. + (eword-analyze-encoded-word): quote non-atoms string as + quoted-string. + +1998-07-18 Tanaka Akira + * Fix character code for ChangeLog. 1998-07-18 Tanaka Akira diff --git a/TESTPAT b/TESTPAT index 7b7402c..82f0605 100644 --- a/TESTPAT +++ b/TESTPAT @@ -1,5 +1,5 @@ ;---------------------------------------------------------------------------- -;-------- This sequece of hyphens is 76 bytes long. ------------------------- +;-------- This sequece of HYPHEN-MINUS is 76 bytes long. -------------------- ;---------------------------------------------------------------------------- ; options: @@ -16,32 +16,34 @@ (defun decode (src dsts &rest opts) (setq eword-lexical-analyze-cache nil) - (setq eword-decode-sticked-encoded-word nil) + (setq eword-decode-sticked-encoded-word + (or (memq 'permit-sticked-comment opts) + (memq 'permit-sticked-special opts))) (setq eword-decode-quoted-encoded-word nil) - (if (memq 'permit-sticked-comment opts) (setq eword-decode-sticked-encoded-word t)) (if (stringp dsts) (setq dsts (list dsts))) (with-temp-buffer - (insert src "\nDummy-Header: \n" mail-header-separator) - (eword-decode-header 'us-ascii) + (insert src "\n" mail-header-separator) + (eword-decode-header 'us-ascii mail-header-separator) (goto-char (point-min)) + (std11-narrow-to-header mail-header-separator) (std11-field-end) (let ((result (buffer-substring (point-min) (point)))) - (if (member result dsts) - t - result)))) + (if (member result dsts) t result)))) (defun encode (src dsts &rest opts) + (setq eword-lexical-analyze-cache nil) + (setq eword-decode-sticked-encoded-word nil) + (setq eword-decode-quoted-encoded-word nil) (if (stringp dsts) (setq dsts (list dsts))) (with-temp-buffer - (insert src "\nDummy-Header: \n" mail-header-separator) + (insert src "\n" mail-header-separator) (goto-char (point-min)) (eword-encode-header 'us-ascii) (goto-char (point-min)) + (std11-narrow-to-header mail-header-separator) (std11-field-end) (let ((result (buffer-substring (point-min) (point)))) - (if (member result dsts) - t - result)))) + (if (member result dsts) t result)))) ;;; from RFC2047 @@ -312,12 +314,16 @@ 'permit-sticked-comment) (decode -"From: =?ISO-2022-JP?B?YSJiGyRCJCIbKEJjXAo=?= " -"From: \"a\"b$B$"(Bc\\\" ") +"From: =?US-ASCII?Q?=28?= , =?US-ASCII?Q?=29?= " +"From: \"(\" , \")\" ") + +(decode +"From: =?ISO-2022-JP?B?YSJiGyRCJCIbKEJjXA==?= " +"From: \"a\\\"b$B$"(Bc\\\\\" ") (encode -"From: "a\"b$B$"(B\\" " -"From: =?ISO-2022-JP?B?YSJiGyRCJCIbKEJjXAo=?= ") +"From: \"a\\\"b$B$"(Bc\\\\\" " +"From: =?ISO-2022-JP?B?YSJiGyRCJCIbKEJjXA==?= ") (decode "To: =?ISO-2022-JP?B?GyRCJCIbKEI=?=" @@ -505,6 +511,15 @@ "Subject: =?ISO-2022-JP?B?DQoNCg==?=" "Subject: ") +(decode +"Subject: =?US-ASCII?Q?a=0D=0A_b?=" +"Subject: a b") + +(decode +"Subject: =?ISO-2022-JP?B?GyRCJCIbKEI=?= a + =?ISO-2022-JP?B?GyRCJCQbKEI=?=" +"From: $B$"(B a $B$$(B") + (encode "Subject: $B0$(B $BR_(B" "Subject: =?ISO-2022-JP?B?GyRCMCQbKEIgICAgICAgICAgICAgICAgICAgICAgICAgICAg?= @@ -535,12 +550,74 @@ "From: .AN! "*B "From: =?ISO-8859-1?Q?=A1?= ") +(decode +"From: =?ISO-8859-1?Q?abcdefghijklmnopqrst=A1=28=29=22=5C?= " +"From: \"abcdefghijklmnopqrst.AN!()\\\"\\\\\" ")*B + (encode -"From: \"abcdefghijklmnopqrstu.AN!()\\\"\\\\\" "*B +"From: \"abcdefghijklmnopqrst.AN!()\\\"\\\\\" "*B "From: =?ISO-8859-1?Q?abcdefghijklmnopqrst=A1=28=29=22=5C?= ") (encode "From: akr@jaist.ac.jp (abcdefghijklmnopqrst.AN!\\(\\)\"\\\\)"*B "From: akr@jaist.ac.jp (=?ISO-8859-1?Q?abcdefghijklmnopqrst=A1=28=29\"=5C?=)") +(decode +"Subject: ?= =?" +"Subject: ?= =?") + +(decode +"Subject: \" =?ISO-2022-JP?B?GyRCJCIbKEI=?= \"" +"Subject: \" $B$"(B \"") + +(decode +"From: \"\\\\\" =?ISO-2022-JP?B?GyRCJCIbKEI=?= \"\" " +"From: \"\\\\\" $B$"(B \"\" ") + +(decode +"Subject: =?ISO-2022-JP?Q?=1B$B$\"=1B(B_=1B$B$\"=1B(B?=" +"Subject: $B$"(B $B$"(B") + +(decode +"Subject: =?ISO-2022-JP?Q?=1B$B$\"=1B(B =1B$B$\"=1B(B?=" +"Subject: =?ISO-2022-JP?Q?=1B$B$\"=1B(B =1B$B$\"=1B(B?=") + +(decode +"Subject: =?ISO-2022-JP?B?GyRCJCIbKEI=?= a =?ISO-8859-8?Q?=E0?=" +"Subject: $B$"(B a .HN`")*B + +(encode +"Subject: $B$"(B a .HN`"*B +"Subject: =?ISO-2022-JP?B?GyRCJCIbKEI=?= a =?ISO-8859-8?Q?=E0?=") + +(decode +"Subject: =?ISO-8859-8?Q?=E0?= =?ISO-2022-JP?B?GyRCTm0bKEI=?=" +"Subject: .HN`$BNm(B")*B + +(encode +"Subject: .HN`$BNm(B"*B +"Subject: =?ISO-8859-8?Q?=E0?= =?ISO-2022-JP?B?GyRCTm0bKEI=?=") + +(decode +"Subject: =?ISO-8859-8?Q?=E0_?= =?ISO-2022-JP?B?GyRCTm0bKEI=?=" +"Subject: .HN` $BNm(B")*B + +(encode +"Subject: .HN` $BNm(B"*B +'("Subject: =?ISO-8859-8?Q?=E0_?= =?ISO-2022-JP?B?GyRCTm0bKEI=?=" + "Subject: =?ISO-8859-8?Q?=E0?= =?ISO-2022-JP?B?IBskQk5tGyhC?=")) + +(encode +"Subject: .FNC$B4X?t(B"*B +'("Subject: =?ISO-8859-7?Q?=C3?= =?ISO-2022-JP?B?GyRCNFg/dBsoQg==?=" + "Subject: =?ISO-2022-JP-2?B?Gy5GG05DGyRCNFg/dBsoQg==?=")) + +(decode +"Subject: =?ISO-2022-JP-2?B?Gy5GG05DGyRCNFg/dBsoQg==?=" +"Subject: .FNC$B4X?t(B")*B + +(decode +"Subject: =?ISO-8859-7?Q?=C3?= =?ISO-2022-JP?B?GyRCNFg/dBsoQg==?=" +"Subject: .FNC$B4X?t(B")*B + ;---------------------------------------------------------------------------- diff --git a/eword-decode.el b/eword-decode.el index fa07ab1..c8a4a0f 100644 --- a/eword-decode.el +++ b/eword-decode.el @@ -575,16 +575,18 @@ be the result." (defun eword-analyze-quoted-string (string &optional must-unfold) (let ((p (std11-check-enclosure string ?\" ?\"))) (if p - (cons (cons 'quoted-string - (if eword-decode-quoted-encoded-word - (eword-decode-quoted-string - (substring string 0 p) - default-mime-charset) - (decode-mime-charset-string - (std11-strip-quoted-pair (substring string 0 p)) - default-mime-charset))) - (substring string p))) - )) + (cons (cons 'quoted-string + (if eword-decode-quoted-encoded-word + (std11-wrap-as-quoted-string + (eword-decode-quoted-string + (substring string 1 (1- p)) + default-mime-charset)) + (std11-wrap-as-quoted-string + (decode-mime-charset-string + (std11-strip-quoted-pair (substring string 1 (1- p))) + default-mime-charset)))) + (substring string p))) + )) (defun eword-analyze-domain-literal (string &optional must-unfold) (std11-analyze-domain-literal string)) @@ -611,12 +613,20 @@ be the result." (defun eword-analyze-encoded-word (string &optional must-unfold) (let ((decoded (eword-decode-first-encoded-words - string - eword-encoded-word-in-phrase-regexp - eword-after-encoded-word-in-phrase-regexp - must-unfold))) + string + eword-encoded-word-in-phrase-regexp + eword-after-encoded-word-in-phrase-regexp + must-unfold))) (if decoded - (cons (cons 'atom (car decoded)) (cdr decoded))))) + (let ((s (car decoded))) + (while (or (string-match std11-atom-regexp s) + (string-match std11-spaces-regexp s)) + (setq s (substring s (match-end 0)))) + (if (= (length s) 0) + (cons (cons 'atom (car decoded)) (cdr decoded)) + (cons (cons 'quoted-string + (std11-wrap-as-quoted-string (car decoded))) + (cdr decoded))))))) (defun eword-analyze-atom (string &optional must-unfold) (if (let ((enable-multibyte-characters nil))