mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-24 15:05:24 +00:00
moving gbk detection code into helper function
This commit is contained in:
parent
88dc16c910
commit
e7d632a726
@ -430,7 +430,7 @@ func (request *Request) executeRequest(reqURL string, generatedRequest *generate
|
||||
|
||||
// Decode gbk response content-types
|
||||
// gb18030 supersedes gb2312
|
||||
if contentType := strings.ToLower(resp.Header.Get("Content-Type")); stringsutil.ContainsAny(contentType, "gbk", "gb2312", "gb18030") {
|
||||
if isContentTypeGbk(resp.Header.Get("Content-Type")) {
|
||||
dumpedResponse, err = decodegbk(dumpedResponse)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not gbk decode")
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/generators"
|
||||
"github.com/projectdiscovery/nuclei/v2/pkg/protocols/common/tostring"
|
||||
"github.com/projectdiscovery/rawhttp"
|
||||
"github.com/projectdiscovery/stringsutil"
|
||||
"golang.org/x/text/encoding/simplifiedchinese"
|
||||
"golang.org/x/text/transform"
|
||||
)
|
||||
@ -135,3 +136,9 @@ func decodegbk(s []byte) ([]byte, error) {
|
||||
}
|
||||
return d, nil
|
||||
}
|
||||
|
||||
// isContentTypeGbk checks if the content-type header is gbk
|
||||
func isContentTypeGbk(contentType string) bool {
|
||||
contentType = strings.ToLower(contentType)
|
||||
return stringsutil.ContainsAny(contentType, "gbk", "gb2312", "gb18030")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user