Skip to content

Commit b42e307

Browse files
committed
net/url: add additional test cases for URL parsing with special characters
1 parent dc1e255 commit b42e307

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

src/net/url/url_test.go

+60
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,66 @@ var urltests = []URLTest{
5454
},
5555
"",
5656
},
57+
{
58+
"http://www.google.com/foo<bar%2Fbaz.txt",
59+
&URL{
60+
Scheme: "http",
61+
Host: "www.google.com",
62+
Path: "/foo<bar/baz.txt",
63+
RawPath: "/foo<bar%2Fbaz.txt",
64+
},
65+
"http://www.google.com/foo%3Cbar%2Fbaz.txt",
66+
},
67+
{
68+
"http://www.google.com/foo>bar%2Fbaz.txt",
69+
&URL{
70+
Scheme: "http",
71+
Host: "www.google.com",
72+
Path: "/foo>bar/baz.txt",
73+
RawPath: "/foo>bar%2Fbaz.txt",
74+
},
75+
"http://www.google.com/foo%3Ebar%2Fbaz.txt",
76+
},
77+
{
78+
"http://www.google.com/foo{bar%2Fbaz.txt",
79+
&URL{
80+
Scheme: "http",
81+
Host: "www.google.com",
82+
Path: "/foo{bar/baz.txt",
83+
RawPath: "/foo{bar%2Fbaz.txt",
84+
},
85+
"http://www.google.com/foo%7Bbar%2Fbaz.txt",
86+
},
87+
{
88+
"http://www.google.com/foo}bar%2Fbaz.txt",
89+
&URL{
90+
Scheme: "http",
91+
Host: "www.google.com",
92+
Path: "/foo}bar/baz.txt",
93+
RawPath: "/foo}bar%2Fbaz.txt",
94+
},
95+
"http://www.google.com/foo%7Dbar%2Fbaz.txt",
96+
},
97+
{
98+
"http://www.google.com/foo bar%2Fbaz.txt",
99+
&URL{
100+
Scheme: "http",
101+
Host: "www.google.com",
102+
Path: "/foo bar/baz.txt",
103+
RawPath: "/foo bar%2Fbaz.txt",
104+
},
105+
"http://www.google.com/foo%20bar%2Fbaz.txt",
106+
},
107+
{
108+
"http://www.google.com/foo\"bar%2Fbaz.txt",
109+
&URL{
110+
Scheme: "http",
111+
Host: "www.google.com",
112+
Path: "/foo\"bar/baz.txt",
113+
RawPath: "/foo\"bar%2Fbaz.txt",
114+
},
115+
"http://www.google.com/foo%22bar%2Fbaz.txt",
116+
},
57117
// fragment with hex escaping
58118
{
59119
"http://www.google.com/#file%20one%26two",

0 commit comments

Comments
 (0)