mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-16 16:17:38 +03:00
Do not escape '-' and '_' in url path and query args
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ import (
|
||||
func TestArgsEscape(t *testing.T) {
|
||||
testArgsEscape(t, "foo", "bar", "foo=bar")
|
||||
testArgsEscape(t, "f.o,1:2/4", "~`!@#$%^&*()_-=+\\|/[]{};:'\"<>,./?",
|
||||
"f.o,1:2/4=%7E%60%21%40%23%24%25%5E%26%2A%28%29%5F%2D%3D%2B%5C%7C/%5B%5D%7B%7D%3B:%27%22%3C%3E,./%3F")
|
||||
"f.o,1:2/4=%7E%60%21%40%23%24%25%5E%26%2A%28%29_-%3D%2B%5C%7C/%5B%5D%7B%7D%3B:%27%22%3C%3E,./%3F")
|
||||
}
|
||||
|
||||
func testArgsEscape(t *testing.T, k, v, expectedS string) {
|
||||
|
||||
+1
-1
@@ -312,7 +312,7 @@ func unsafeBytesToStr(b []byte) string {
|
||||
func appendQuotedArg(dst, v []byte) []byte {
|
||||
for _, c := range v {
|
||||
if c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' ||
|
||||
c == '/' || c == '.' || c == ',' || c == ':' {
|
||||
c == '/' || c == '.' || c == ',' || c == ':' || c == '-' || c == '_' {
|
||||
dst = append(dst, c)
|
||||
} else {
|
||||
dst = append(dst, '%', hexCharUpper(c>>4), hexCharUpper(c&15))
|
||||
|
||||
@@ -438,7 +438,7 @@ func (x *URI) parseQueryArgs() {
|
||||
func appendQuotedPath(dst, v []byte) []byte {
|
||||
for _, c := range v {
|
||||
if c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' ||
|
||||
c == '/' || c == '.' || c == ',' || c == '=' || c == ':' || c == '&' || c == '~' {
|
||||
c == '/' || c == '.' || c == ',' || c == '=' || c == ':' || c == '&' || c == '~' || c == '-' || c == '_' {
|
||||
dst = append(dst, c)
|
||||
} else {
|
||||
dst = append(dst, '%', hexCharUpper(c>>4), hexCharUpper(c&15))
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func TestURIPathEscape(t *testing.T) {
|
||||
testURIPathEscape(t, "/foo/bar", "/foo/bar")
|
||||
testURIPathEscape(t, "/foo=b:ar,b.c&q", "/foo=b:ar,b.c&q")
|
||||
testURIPathEscape(t, "/f_o-o=b:ar,b.c&q", "/f_o-o=b:ar,b.c&q")
|
||||
testURIPathEscape(t, "/aa?bb.тест~qq", "/aa%3Fbb.%D1%82%D0%B5%D1%81%D1%82~qq")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user