Disable hz-gb-2312 encoding support

This commit is contained in:
fox.cpp 2020-05-14 20:30:33 +03:00
parent 5523a84866
commit 3a93fc61e3
No known key found for this signature in database
GPG key ID: 5B991F6215D2FCC0

37
xtext_bug.go Normal file
View file

@ -0,0 +1,37 @@
//+build !hz_gb_2312
package maddy
import (
"errors"
"github.com/emersion/go-message/charset"
"golang.org/x/text/encoding"
)
/*
Disallow hz-gb-2312 encoding as it can trigger OOM crash.
https://github.com/emersion/go-message/issues/95
https://github.com/golang/go/issues/35118
*/
type dummyEncoding struct{}
func (dummyEncoding) NewDecoder() *encoding.Decoder {
return &encoding.Decoder{Transformer: dummyEncoding{}}
}
func (dummyEncoding) NewEncoder() *encoding.Encoder {
return &encoding.Encoder{Transformer: dummyEncoding{}}
}
func (dummyEncoding) Reset() {}
func (dummyEncoding) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
return 0, 0, errors.New("hz-gb-2312 decoding is disabled due to known issues")
}
func init() {
charset.RegisterEncoding("hz-gb-2312", dummyEncoding{})
}