new: new request.ParseForm builtin method for proxy modules.

This commit is contained in:
evilsocket 2018-01-13 17:00:50 +01:00
parent 87971a19e3
commit a296dacd74
4 changed files with 31 additions and 36 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
@ -63,3 +64,26 @@ func (j *JSRequest) ReadBody() string {
return j.Body
}
func (j *JSRequest) ParseForm() map[string]string {
if j.Body == "" {
j.Body = j.ReadBody()
}
form := make(map[string]string, 0)
parts := strings.Split(j.Body, "&")
for _, part := range parts {
nv := strings.SplitN(part, "=", 2)
if len(nv) == 2 {
unescaped, err := url.QueryUnescape(nv[1])
if err == nil {
form[nv[0]] = unescaped
} else {
form[nv[0]] = nv[1]
}
}
}
return form
}