diff options
| author | Russ Cox <rsc@golang.org> | 2021-01-13 10:53:48 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-03-25 19:04:59 +0000 |
| commit | 2bbf383774952c8ddc309a45c024af76b47ea1fe (patch) | |
| tree | 487cbb9b55efa5fe2b0ee9cf1cd8a67dc832a836 /src/net/mail/message_test.go | |
| parent | f25631b490c7ccb8e555b4031dc12046b2534c11 (diff) | |
| download | go-2bbf383774952c8ddc309a45c024af76b47ea1fe.tar.xz | |
net/mail: improve detection of charset errors
The detection of the "unknown charset" case was too tailored
to one specific address parser. Make it generalize, so that custom
address parsers behave the same way as the default one
for character sets they do not handle.
Fixes #41625.
Change-Id: I347d4bb6844d0a1f23e908b776d21e8be5af3874
Reviewed-on: https://go-review.googlesource.com/c/go/+/283632
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/net/mail/message_test.go')
| -rw-r--r-- | src/net/mail/message_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/net/mail/message_test.go b/src/net/mail/message_test.go index 80a17b2853..41c54b8687 100644 --- a/src/net/mail/message_test.go +++ b/src/net/mail/message_test.go @@ -344,6 +344,17 @@ func TestAddressParsingError(t *testing.T) { t.Errorf(`mail.ParseAddress(%q) #%d want %q, got %v`, tc.text, i, tc.wantErrText, err) } } + + t.Run("CustomWordDecoder", func(t *testing.T) { + p := &AddressParser{WordDecoder: &mime.WordDecoder{}} + for i, tc := range mustErrTestCases { + _, err := p.Parse(tc.text) + if err == nil || !strings.Contains(err.Error(), tc.wantErrText) { + t.Errorf(`p.Parse(%q) #%d want %q, got %v`, tc.text, i, tc.wantErrText, err) + } + } + }) + } func TestAddressParsing(t *testing.T) { |
