Skip to content

Commit

Permalink
charset: re-enable hz-gb-2312
Browse files Browse the repository at this point in the history
The upstream Go issue has been fixed [1].

[1]: golang/go#35118

References: #95
  • Loading branch information
emersion committed Nov 25, 2020
1 parent 2b5070c commit e7268f8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions charset/charset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 18,12 @@ import (

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

func init() {
Expand Down
11 changes: 4 additions & 7 deletions charset/charset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 79,10 @@ func TestCharsetReader(t *testing.T) {
}

func TestDisabledCharsetReader(t *testing.T) {
_, err := Reader("hz-gb-2312", strings.NewReader("Some dummy text"))
charsets["DISABLED"] = nil

_, err := Reader("DISABLED", strings.NewReader("Some dummy text"))
if err == nil {
t.Errorf("%v encoding is disabled and should give an error", "hz-gb-2312")
return
}
if !strings.HasSuffix(err.Error(), "charset is disabled") {
t.Errorf("expected error to end in 'charset is disabled', got %v",
err.Error())
t.Errorf("Reader(): expected disabled charset to return an error")
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 7,5 @@ require (
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831863
github.com/martinlindhe/base36 v1.1.0
github.com/stretchr/testify v1.3.0 // indirect
golang.org/x/text v0.3.4-0.20201021145329-22f1617af38e
golang.org/x/text v0.3.5-0.20201125200606-c27b9fd57aec
)
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 11,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF rwdDfMAkV7OtwuqBVzrE8GR6GFx wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn 9EI=
golang.org/x/text v0.3.3 h1:cokOdA Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4-0.20201021145329-22f1617af38e h1:0kyKOEC0chG7FKmnf/1uNwvDLc3NtNTRip2rXAN9nwI=
golang.org/x/text v0.3.4-0.20201021145329-22f1617af38e/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5-0.20201125200606-c27b9fd57aec h1:A1qYjneJuzBZZ2gIB8rd6zrfq6l7SoEMJ8EsSilNK/U=
golang.org/x/text v0.3.5-0.20201125200606-c27b9fd57aec/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

0 comments on commit e7268f8

Please sign in to comment.