| index ed4435f6c..dc1c2760b 100644 |
| --- a/internal/mailer/hygiene_test.go |
| +++ b/internal/mailer/hygiene_test.go |
| @@ -164,16 +164,19 @@ func TestHeaderBlockRefusesEncodedControls(t *testing.T) { |
| "List-Id": msg("From: "+from, "List-Id: =?utf-8?q?x=0Ay?= <list.example.org>"), |
| "Content-Type name=": msg("From: "+from, `Content-Type: application/pdf; name="=?utf-8?q?x=0Ay.pdf?="`), |
| // Ruled 2026-11-14: every RFC 2231 parameter is refused up front, |
| - // whatever it decodes to. Six spellings: extended, extended and |
| - // continued, continued plain, an empty charset, spaced and upper |
| - // case, and in a field that is not MIME's. |
| - "RFC 2231 extended": msg("From: "+from, "Content-Disposition: attachment; filename*=utf-8''x%0D%0ABcc%3A%20v"), |
| - "RFC 2231 extended, continued": msg("From: "+from, "Content-Disposition: attachment;", " filename*0*=utf-8''a; filename*1*=%0Ab"), |
| - "RFC 2231 continued, plain": msg("From: "+from, `Content-Type: application/pdf; name*0="a"; name*1="b.pdf"`), |
| - "RFC 2231 empty charset": msg("From: "+from, "Content-Type: text/plain; name*=''%0A"), |
| - "RFC 2231 spaced, upper case": msg("From: "+from, "Content-Type: text/plain; NAME *= UTF-7''%2BAA0ACg-"), |
| - "RFC 2231 in another field": msg("From: "+from, "X-Note: a; title*=utf-8''caf%C3%A9"), |
| - "RFC 2231, clean": msg("From: "+from, "Content-Disposition: attachment; filename*=utf-8'en'caf%C3%A9.pdf"), |
| + // whatever it decodes to, in a structured MIME field (Content-Type, |
| + // Content-Disposition; Task 6 review P3: anywhere in it, the first |
| + // parameter included). Spellings: extended, extended and continued, |
| + // continued plain, an empty charset, spaced and upper case, with no |
| + // ";" before it, name*0=. |
| + "RFC 2231 extended": msg("From: "+from, "Content-Disposition: attachment; filename*=utf-8''x%0D%0ABcc%3A%20v"), |
| + "RFC 2231 extended, continued": msg("From: "+from, "Content-Disposition: attachment;", " filename*0*=utf-8''a; filename*1*=%0Ab"), |
| + "RFC 2231 continued, plain": msg("From: "+from, `Content-Type: application/pdf; name*0="a"; name*1="b.pdf"`), |
| + "RFC 2231 empty charset": msg("From: "+from, "Content-Type: text/plain; name*=''%0A"), |
| + "RFC 2231 spaced, upper case": msg("From: "+from, "Content-Type: text/plain; NAME *= UTF-7''%2BAA0ACg-"), |
| + "RFC 2231, the first parameter with no ;": msg("From: "+from, "Content-Disposition: attachment filename*=utf-8''x%0D%0ABcc%3A%20v"), |
| + "RFC 2231 name*0= in Content-Type": msg("From: "+from, "Content-Type: text/plain; name*0=a"), |
| + "RFC 2231, clean": msg("From: "+from, "Content-Disposition: attachment; filename*=utf-8'en'caf%C3%A9.pdf"), |
| // Ruled 2026-11-14, the family's P3s. |
| "invalid UTF-8 in a utf-8 word": msg("From: "+from, "Subject: =?utf-8?q?a=E2=80?="), |
| "U+2028 split across two words": msg("From: "+from, "Subject: =?utf-8?q?a=E2=80?= =?utf-8?q?=A8b?="), |
| @@ -193,21 +196,23 @@ func TestHeaderBlockRefusesEncodedControls(t *testing.T) { |
| } |
| } |
| for name, raw := range map[string][]byte{ |
| - "B, a UTF-8 name": msg("From: =?utf-8?b?Y2Fmw6k=?= <" + from + ">"), |
| - "Q, a UTF-8 name": msg("From: =?utf-8?q?caf=C3=A9?= <" + from + ">"), |
| - "Q, a tab": msg("From: "+from, "Subject: =?utf-8?q?a=09b?="), |
| - "ISO-2022-JP's ESC": msg("From: "+from, "Subject: =?iso-2022-jp?b?GyRCJEokcyQrGyhC?="), |
| - "no encoded word": msg("From: Docs <"+from+">", "Subject: =? not a word"), |
| - "a folded subject": msg("From: "+from, "Subject: =?utf-8?q?caf=C3=A9?=", " =?utf-8?q?_au_lait?="), |
| - "windows-1252": msg("From: "+from, "Subject: =?windows-1252?q?=93quoted=94?="), |
| - "Shift_JIS": msg("From: "+from, "Subject: =?Shift_JIS?B?g26DjYFb?="), |
| - "a language suffix": msg("From: "+from, "Subject: =?utf-8*en?q?hello?="), |
| - "a star, not in a parameter": msg("From: "+from, "Subject: a*=b"), |
| - "=? and ?= that are not a word": msg("From: "+from, "Subject: is a=?b then c?=d"), |
| - "a URL holding =? and ?=": msg("From: "+from, "List-Unsubscribe: <https://example.org/u?x=?1&y=2?=3>"), |
| - "=? with too few ?": msg("From: "+from, "Subject: =?utf-8?=0A?="), |
| - "a plain parameter": msg("From: "+from, `Content-Type: application/pdf; name="report.pdf"`), |
| - "a URL with ?=": msg("From: "+from, "List-Unsubscribe: <https://example.org/u?id=1&t=2>"), |
| + "B, a UTF-8 name": msg("From: =?utf-8?b?Y2Fmw6k=?= <" + from + ">"), |
| + "Q, a UTF-8 name": msg("From: =?utf-8?q?caf=C3=A9?= <" + from + ">"), |
| + "Q, a tab": msg("From: "+from, "Subject: =?utf-8?q?a=09b?="), |
| + "ISO-2022-JP's ESC": msg("From: "+from, "Subject: =?iso-2022-jp?b?GyRCJEokcyQrGyhC?="), |
| + "no encoded word": msg("From: Docs <"+from+">", "Subject: =? not a word"), |
| + "a folded subject": msg("From: "+from, "Subject: =?utf-8?q?caf=C3=A9?=", " =?utf-8?q?_au_lait?="), |
| + "windows-1252": msg("From: "+from, "Subject: =?windows-1252?q?=93quoted=94?="), |
| + "Shift_JIS": msg("From: "+from, "Subject: =?Shift_JIS?B?g26DjYFb?="), |
| + "a language suffix": msg("From: "+from, "Subject: =?utf-8*en?q?hello?="), |
| + "a parameter star outside a MIME field": msg("From: "+from, "Subject: note; x*=2 works"), |
| + "RFC 2231 in a field that is not MIME's": msg("From: "+from, "X-Note: a; title*=utf-8''caf%C3%A9"), |
| + "a star, not in a parameter": msg("From: "+from, "Subject: a*=b"), |
| + "=? and ?= that are not a word": msg("From: "+from, "Subject: is a=?b then c?=d"), |
| + "a URL holding =? and ?=": msg("From: "+from, "List-Unsubscribe: <https://example.org/u?x=?1&y=2?=3>"), |
| + "=? with too few ?": msg("From: "+from, "Subject: =?utf-8?=0A?="), |
| + "a plain parameter": msg("From: "+from, `Content-Type: application/pdf; name="report.pdf"`), |
| + "a URL with ?=": msg("From: "+from, "List-Unsubscribe: <https://example.org/u?id=1&t=2>"), |
| } { |
| if _, err := headerBlock(raw); err != nil { |
| t.Errorf("%s: headerBlock refused %q: %v", name, raw, err) |