package urlutil
import (
"fmt"
"net/http"
"net/url"
"testing"
"github.com/stretchr/testify/require"
)
func TestUTF8URLEncoding(t *testing.T) {
exstring := '上'
expected := `e4%b8%8a`
val := getutf8hex(exstring)
require.Equalf(t, val, expected, "failed to url encode utf char expected %v but got %v", expected, val)
}
func TestParamEncoding(t *testing.T) {
testcases := []struct {
Payload string
Expected string
}{
{"1+AND+(SELECT+*+FROM+(SELECT(SLEEP(12)))nQIP)", "1+AND+(SELECT+*+FROM+(SELECT(SLEEP(12)))nQIP)"},
{"1 AND SELECT", "1+AND+SELECT"},
}
for _, v := range testcases {
val := ParamEncode(v.Payload)
require.Equalf(t, val, v.Expected, "failed to url encode payload expected %v got %v", v.Expected, val)
}
}
func TestRawParam(t *testing.T) {
p := NewParams()
p.Add("sqli", "1+AND+(SELECT+*+FROM+(SELECT(SLEEP(12)))nQIP)")
p.Add("xss", "")
p.Add("xssiwthspace", "