1
0
Fork 0

Update XML encoding regex to take single quotes into consideration

This commit is contained in:
Frédéric Guillot 2018-12-12 21:13:06 -08:00
parent 266d97ad63
commit 82e08d0f69
3 changed files with 6219 additions and 1 deletions

View file

@ -15,7 +15,7 @@ import (
"golang.org/x/net/html/charset"
)
var xmlEncodingRegex = regexp.MustCompile(`<\?xml(.*)encoding="(.+)"(.*)\?>`)
var xmlEncodingRegex = regexp.MustCompile(`<\?xml(.*)encoding=["'](.+)["'](.*)\?>`)
// Response wraps a server response.
type Response struct {

View file

@ -124,6 +124,7 @@ func TestEnsureUnicodeWithHTMLDocuments(t *testing.T) {
{"charset-content-type-xml-iso88591.xml", "application/rss+xml; charset=ISO-8859-1", false},
{"windows_1251.xml", "text/xml", false},
{"smallfile.xml", "text/xml; charset=utf-8", true},
{"single_quote_xml_encoding.xml", "text/xml; charset=utf-8", true},
}
for _, tc := range unicodeTestCases {

File diff suppressed because it is too large Load diff