diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2017-12-07 14:09:41 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2017-12-07 14:09:41 +0200 |
commit | e5f51c11919d4f66400334047b897ef0a94c6f3c (patch) | |
tree | 771d25538f5d3f3eaf5c9b6399f2601f7c3bbaae /args_test.go | |
parent | attempt #2 to fix TestTCP6 on travis: run the test only if local tcp6 interfa... (diff) | |
download | fasthttp-e5f51c11919d4f66400334047b897ef0a94c6f3c.tar.gz fasthttp-e5f51c11919d4f66400334047b897ef0a94c6f3c.tar.bz2 fasthttp-e5f51c11919d4f66400334047b897ef0a94c6f3c.zip |
added missing byte 0xFF into hex2intTable. This fixes panic when decoding specially crafted string like "%\xff"v20180529
Diffstat (limited to 'args_test.go')
-rw-r--r-- | args_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/args_test.go b/args_test.go index c50bdf3..d5b768f 100644 --- a/args_test.go +++ b/args_test.go @@ -8,6 +8,27 @@ import ( "time" ) +func TestDecodeArgAppend(t *testing.T) { + testDecodeArgAppend(t, "", "") + testDecodeArgAppend(t, "foobar", "foobar") + testDecodeArgAppend(t, "тест", "тест") + testDecodeArgAppend(t, "a%", "a%") + testDecodeArgAppend(t, "%a%21", "%a!") + testDecodeArgAppend(t, "ab%test", "ab%test") + testDecodeArgAppend(t, "d%тестF", "d%тестF") + testDecodeArgAppend(t, "a%\xffb%20c", "a%\xffb c") + testDecodeArgAppend(t, "foo%20bar", "foo bar") + testDecodeArgAppend(t, "f.o%2C1%3A2%2F4=%7E%60%21%40%23%24%25%5E%26*%28%29_-%3D%2B%5C%7C%2F%5B%5D%7B%7D%3B%3A%27%22%3C%3E%2C.%2F%3F", + "f.o,1:2/4=~`!@#$%^&*()_-=+\\|/[]{};:'\"<>,./?") +} + +func testDecodeArgAppend(t *testing.T, s, expectedResult string) { + result := decodeArgAppend(nil, []byte(s)) + if string(result) != expectedResult { + t.Fatalf("unexpected decodeArgAppend(%q)=%q; expecting %q", s, result, expectedResult) + } +} + func TestArgsAdd(t *testing.T) { var a Args a.Add("foo", "bar") |