Do not escape '-' and '_' in url path and query args

This commit is contained in:
Aliaksandr Valialkin
2015-12-22 20:18:19 +02:00
parent b3c0a2cf75
commit ea8a7f54d5
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -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
View File
@@ -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))
+1 -1
View File
@@ -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
View File
@@ -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")
}