| 1 |
(require 'lunit) |
| 2 |
(require 'mime) |
| 3 |
|
| 4 |
(luna-define-class test-rfc2231 (lunit-test-case)) |
| 5 |
|
| 6 |
;;; |
| 7 |
;;; Parameter Value Continuations |
| 8 |
;;; |
| 9 |
|
| 10 |
;; The content-type field |
| 11 |
;; |
| 12 |
;; Content-Type: message/external-body; access-type=URL; |
| 13 |
;; URL*0="ftp://"; |
| 14 |
;; URL*1="cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar" |
| 15 |
;; |
| 16 |
;; is semantically identical to |
| 17 |
;; |
| 18 |
;; Content-Type: message/external-body; access-type=URL; |
| 19 |
;; URL="ftp://cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar" |
| 20 |
;; |
| 21 |
(luna-define-method test-rfc2231-continuation-1 ((case test-rfc2231)) |
| 22 |
(lunit-assert |
| 23 |
(eq |
| 24 |
(mime-content-type-primary-type |
| 25 |
(mime-parse-Content-Type "message/external-body; access-type=URL; |
| 26 |
URL*0=\"ftp://\"; |
| 27 |
URL*1=\"cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar\"")) |
| 28 |
(mime-content-type-primary-type |
| 29 |
(mime-parse-Content-Type "message/external-body; access-type=URL; |
| 30 |
URL=\"ftp://cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar\""))))) |
| 31 |
|
| 32 |
(luna-define-method test-rfc2231-continuation-2 ((case test-rfc2231)) |
| 33 |
(lunit-assert |
| 34 |
(eq |
| 35 |
(mime-content-type-subtype |
| 36 |
(mime-parse-Content-Type "message/external-body; access-type=URL; |
| 37 |
URL*0=\"ftp://\"; |
| 38 |
URL*1=\"cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar\"")) |
| 39 |
(mime-content-type-subtype |
| 40 |
(mime-parse-Content-Type "message/external-body; access-type=URL; |
| 41 |
URL=\"ftp://cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar\""))))) |
| 42 |
|
| 43 |
(luna-define-method test-rfc2231-continuation-3 ((case test-rfc2231)) |
| 44 |
(lunit-assert |
| 45 |
(string= |
| 46 |
(mime-content-type-parameter |
| 47 |
(mime-parse-Content-Type "message/external-body; access-type=URL; |
| 48 |
URL*0=\"ftp://\"; |
| 49 |
URL*1=\"cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar\"") |
| 50 |
"access-type") |
| 51 |
(mime-content-type-parameter |
| 52 |
(mime-parse-Content-Type "message/external-body; access-type=URL; |
| 53 |
URL=\"ftp://cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar\"") |
| 54 |
"access-type")))) |
| 55 |
|
| 56 |
(luna-define-method test-rfc2231-continuation-4 ((case test-rfc2231)) |
| 57 |
(lunit-assert |
| 58 |
(string= |
| 59 |
(mime-content-type-parameter |
| 60 |
(mime-parse-Content-Type "message/external-body; access-type=URL; |
| 61 |
URL*0=\"ftp://\"; |
| 62 |
URL*1=\"cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar\"") |
| 63 |
"url") |
| 64 |
(mime-content-type-parameter |
| 65 |
(mime-parse-Content-Type "message/external-body; access-type=URL; |
| 66 |
URL=\"ftp://cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar\"") |
| 67 |
"url")))) |
| 68 |
|
| 69 |
;;; |
| 70 |
;;; Parameter Value Character Set and Language Information |
| 71 |
;;; |
| 72 |
|
| 73 |
;; Content-Type: application/x-stuff; |
| 74 |
;; title*=us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A |
| 75 |
(luna-define-method test-rfc2231-charset-language-1 ((case test-rfc2231)) |
| 76 |
(lunit-assert |
| 77 |
(string= |
| 78 |
(mime-content-type-parameter |
| 79 |
(mime-parse-Content-Type "application/x-stuff; |
| 80 |
title*=us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A") |
| 81 |
"title") |
| 82 |
"This is ***fun***"))) |
| 83 |
|
| 84 |
(luna-define-method test-rfc2231-charset-language-2 ((case test-rfc2231)) |
| 85 |
(lunit-assert |
| 86 |
(string= |
| 87 |
(mime-content-type-parameter |
| 88 |
(mime-parse-Content-Type "application/x-stuff; |
| 89 |
title*=''This%20is%20%2A%2A%2Afun%2A%2A%2A") |
| 90 |
"title") |
| 91 |
"This is ***fun***"))) |
| 92 |
|
| 93 |
;;; |
| 94 |
;;; Combining Character Set, Language, and Parameter Continuations |
| 95 |
;;; |
| 96 |
|
| 97 |
;; Content-Type: application/x-stuff; |
| 98 |
;; title*0*=us-ascii'en'This%20is%20even%20more%20; |
| 99 |
;; title*1*=%2A%2A%2Afun%2A%2A%2A%20; |
| 100 |
;; title*2="isn't it!" |
| 101 |
(luna-define-method test-rfc2231-charset-language-continuation-1 ((case test-rfc2231)) |
| 102 |
(lunit-assert |
| 103 |
(string= |
| 104 |
(mime-content-type-parameter |
| 105 |
(mime-parse-Content-Type "application/x-stuff; |
| 106 |
title*0*=us-ascii'en'This%20is%20even%20more%20; |
| 107 |
title*1*=%2A%2A%2Afun%2A%2A%2A%20; |
| 108 |
title*2=\"isn't it!\"") |
| 109 |
"title") |
| 110 |
"This is even more ***fun*** isn't it!"))) |
| 111 |
|
| 112 |
;; MIME states that parameters are not order sensitive. |
| 113 |
(luna-define-method test-rfc2231-charset-language-continuation-2 ((case test-rfc2231)) |
| 114 |
(lunit-assert |
| 115 |
(string= |
| 116 |
(mime-content-type-parameter |
| 117 |
(mime-parse-Content-Type "application/x-stuff; |
| 118 |
title*2=\"isn't it!\"; |
| 119 |
title*1*=%2A%2A%2Afun%2A%2A%2A%20; |
| 120 |
title*0*=us-ascii'en'This%20is%20even%20more%20") |
| 121 |
"title") |
| 122 |
"This is even more ***fun*** isn't it!"))) |
| 123 |
|
| 124 |
;; ABNF states that `ext-octet' is case-insensitive. |
| 125 |
(luna-define-method test-rfc2231-charset-language-continuation-3 ((case test-rfc2231)) |
| 126 |
(lunit-assert |
| 127 |
(let ((case-fold-search nil)) |
| 128 |
(string= |
| 129 |
(mime-content-type-parameter |
| 130 |
(mime-parse-Content-Type "application/x-stuff; |
| 131 |
title*=us-ascii'en-us'This%20is%20%2a%2a%2afun%2a%2a%2a") |
| 132 |
"title") |
| 133 |
"This is ***fun***")))) |
| 134 |
|
| 135 |
;; unencoded segments MUST NOT be decoded. |
| 136 |
(luna-define-method test-rfc2231-charset-language-continuation-4 ((case test-rfc2231)) |
| 137 |
(lunit-assert |
| 138 |
(string= |
| 139 |
(mime-content-type-parameter |
| 140 |
(mime-parse-Content-Type "application/x-stuff; |
| 141 |
title*0*=us-ascii'en'This%20is%20even%20more%20; |
| 142 |
title*1*=%2A%2A%2Afun%2A%2A%2A%20; |
| 143 |
title*2=\"isn%27t%20it!\"") |
| 144 |
"title") |
| 145 |
"This is even more ***fun*** isn%27t%20it!"))) |
| 146 |
|
| 147 |
;;; |
| 148 |
;;; Language specification in Encoded Words |
| 149 |
;;; |
| 150 |
|
| 151 |
(luna-define-method test-rfc2231-encoded-word-1 ((case test-rfc2231)) |
| 152 |
(lunit-assert |
| 153 |
(string= |
| 154 |
(eword-decode-string "=?US-ASCII?Q?Keith_Moore?=") |
| 155 |
"Keith Moore"))) |
| 156 |
|
| 157 |
(luna-define-method test-rfc2231-encoded-word-2 ((case test-rfc2231)) |
| 158 |
(lunit-assert |
| 159 |
(string= |
| 160 |
(eword-decode-string "=?US-ASCII*EN?Q?Keith_Moore?=") |
| 161 |
"Keith Moore"))) |
| 162 |
|
| 163 |
(luna-define-method test-rfc2231-encoded-word-3 ((case test-rfc2231)) |
| 164 |
(lunit-assert |
| 165 |
(eq |
| 166 |
(get-text-property |
| 167 |
0 'mime-language |
| 168 |
(eword-decode-string "=?US-ASCII*EN?Q?Keith_Moore?=")) |
| 169 |
'en))) |
| 170 |
|
| 171 |
;;; |
| 172 |
;;; Language specification in FLIM |
| 173 |
;;; |
| 174 |
|
| 175 |
;; both flim-1_13-rfc2231 and flim-1_14-rfc2231 choose to put language |
| 176 |
;; info to the `mime-language' text-property of the parameter value. |
| 177 |
|
| 178 |
(luna-define-method test-rfc2231-mime-language-1 ((case test-rfc2231)) |
| 179 |
(lunit-assert |
| 180 |
(eq |
| 181 |
(get-text-property |
| 182 |
0 'mime-language |
| 183 |
(mime-content-type-parameter |
| 184 |
(mime-parse-Content-Type "application/x-stuff; |
| 185 |
title*=us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A") |
| 186 |
"title")) |
| 187 |
'en-us))) |
| 188 |
|
| 189 |
(luna-define-method test-rfc2231-mime-language-2 ((case test-rfc2231)) |
| 190 |
(lunit-assert |
| 191 |
(eq |
| 192 |
(get-text-property |
| 193 |
0 'mime-language |
| 194 |
(mime-content-type-parameter |
| 195 |
(mime-parse-Content-Type "application/x-stuff; |
| 196 |
title*=US-ASCII'EN-US'This%20is%20%2A%2A%2Afun%2A%2A%2A") |
| 197 |
"title")) |
| 198 |
'en-us))) |
| 199 |
|
| 200 |
(luna-define-method test-rfc2231-mime-language-3 ((case test-rfc2231)) |
| 201 |
(lunit-assert |
| 202 |
(null |
| 203 |
(get-text-property |
| 204 |
0 'mime-language |
| 205 |
(mime-content-type-parameter |
| 206 |
(mime-parse-Content-Type "application/x-stuff; |
| 207 |
title*=us-ascii''This%20is%20%2A%2A%2Afun%2A%2A%2A") |
| 208 |
"title"))))) |
| 209 |
|
| 210 |
(luna-define-method test-rfc2231-mime-language-4 ((case test-rfc2231)) |
| 211 |
(lunit-assert |
| 212 |
(null |
| 213 |
(get-text-property |
| 214 |
0 'mime-language |
| 215 |
(mime-content-type-parameter |
| 216 |
(mime-parse-Content-Type "application/x-stuff; |
| 217 |
title*=''This%20is%20%2A%2A%2Afun%2A%2A%2A") |
| 218 |
"title"))))) |