mirror of
https://github.com/projectdiscovery/httpx.git
synced 2024-09-11 17:46:08 +03:00
Improve GBK encode
This commit is contained in:
parent
fd07f1cf15
commit
89351c1fdd
@ -28,6 +28,27 @@ func ExtractTitle(r *Response) (title string) {
|
||||
|
||||
return string(titleUtf8)
|
||||
}
|
||||
|
||||
// Content-Type from head tag
|
||||
re = regexp.MustCompile(`(?im)\s*charset="(.*?)"|charset=(.*?)"\s*`)
|
||||
var match = re.FindSubmatch(r.Data)
|
||||
var mcontentType = ""
|
||||
if len(match) != 0 {
|
||||
for i, v := range match {
|
||||
if string(v) != "" && i != 0 {
|
||||
mcontentType = string(v)
|
||||
}
|
||||
}
|
||||
mcontentType = strings.ToLower(mcontentType)
|
||||
}
|
||||
if strings.Contains(mcontentType, "gb2312") || strings.Contains(mcontentType, "gbk") {
|
||||
titleUtf8, err := Decodegbk([]byte(title))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return string(titleUtf8)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user