mirror of
https://github.com/bettercap/bettercap
synced 2025-07-06 13:02:12 -07:00
new: new request.ParseForm builtin method for proxy modules.
This commit is contained in:
parent
87971a19e3
commit
a296dacd74
4 changed files with 31 additions and 36 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue