!1 修复gxml中当encoding为空时的报错

Merge pull request !1 from 蚊子/master
This commit is contained in:
蚊子 2018-07-04 12:46:39 +08:00 committed by John
commit 4255417cc3

View File

@ -61,10 +61,15 @@ func prepare(xmlbyte []byte) error {
if err != nil {
return err
}
xmlEncode := "UTF-8"
if len(matchStr) == 2 {
xmlEncode = matchStr[1]
}
charset := mahonia.GetCharset(matchStr[1])
charset := mahonia.GetCharset(xmlEncode)
if charset == nil {
return errors.New(fmt.Sprintf("not support charset:%s", matchStr[1]))
return errors.New(fmt.Sprintf("not support charset:%s", xmlEncode))
}
if !strings.EqualFold(charset.Name, "UTF-8") {