Skip to content

Commit e7268f8

Browse files
committed
charset: re-enable hz-gb-2312
The upstream Go issue has been fixed [1]. [1]: golang/go#35118 References: #95
1 parent 2b5070c commit e7268f8

4 files changed

Lines changed: 9 additions & 14 deletions

File tree

charset/charset.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import (
1818

1919
// Quirks table for charsets not handled by ianaindex
2020
//
21+
// A nil entry disables the charset.
22+
//
2123
// For aliases, see
2224
// https://www.iana.org/assignments/character-sets/character-sets.xhtml
2325
var charsets = map[string]encoding.Encoding{
2426
"ansi_x3.110-1983": charmap.ISO8859_1, // see RFC 1345 page 62, mostly superset of ISO 8859-1
25-
// disabled due to https://github.com/emersion/go-message/issues/95
26-
"hz-gb-2312": nil,
2727
}
2828

2929
func init() {

charset/charset_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,10 @@ func TestCharsetReader(t *testing.T) {
7979
}
8080

8181
func TestDisabledCharsetReader(t *testing.T) {
82-
_, err := Reader("hz-gb-2312", strings.NewReader("Some dummy text"))
82+
charsets["DISABLED"] = nil
83+
84+
_, err := Reader("DISABLED", strings.NewReader("Some dummy text"))
8385
if err == nil {
84-
t.Errorf("%v encoding is disabled and should give an error", "hz-gb-2312")
85-
return
86-
}
87-
if !strings.HasSuffix(err.Error(), "charset is disabled") {
88-
t.Errorf("expected error to end in 'charset is disabled', got %v",
89-
err.Error())
86+
t.Errorf("Reader(): expected disabled charset to return an error")
9087
}
9188
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ require (
77
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594
88
github.com/martinlindhe/base36 v1.1.0
99
github.com/stretchr/testify v1.3.0 // indirect
10-
golang.org/x/text v0.3.4-0.20201021145329-22f1617af38e
10+
golang.org/x/text v0.3.5-0.20201125200606-c27b9fd57aec
1111
)

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
1111
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
1212
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
1313
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
14-
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
15-
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
16-
golang.org/x/text v0.3.4-0.20201021145329-22f1617af38e h1:0kyKOEC0chG7FKmnf/1uNwvDLc3NtNTRip2rXAN9nwI=
17-
golang.org/x/text v0.3.4-0.20201021145329-22f1617af38e/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
14+
golang.org/x/text v0.3.5-0.20201125200606-c27b9fd57aec h1:A1qYjneJuzBZZ2gIB8rd6zrfq6l7SoEMJ8EsSilNK/U=
15+
golang.org/x/text v0.3.5-0.20201125200606-c27b9fd57aec/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
1816
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

0 commit comments

Comments
 (0)