1 description("Test URLs that have a query string.");
4 // Regular ASCII case in some different encodings.
5 ["foo=bar", "foo=bar"],
6 // Allow question marks in the query without escaping
8 // Always escape '#' since it would mark the ref.
9 // Disabled because this test requires being able to set the query directly.
10 // ["as#df", "as%23df"],
11 // Escape some questionable 8-bit characters, but never unescape.
12 ["\\x02hello\x7f bye", "%02hello%7F%20bye"],
13 ["%40%41123", "%40%41123"],
14 // Chinese input/output
15 ["q=\u4F60\u597D", "q=%26%2320320%3B%26%2322909%3B"],
16 // Invalid UTF-8/16 input should be replaced with invalid characters.
17 ["q=\\ud800\\ud800", "q=%26%2355296%3B%26%2355296%3B"],
18 // Don't allow < or > because sometimes they are used for XSS if the
19 // URL is echoed in content. Firefox does this, IE doesn't.
20 ["q=<asdf>", "q=%3Casdf%3E"],
21 // Escape double quotemarks in the query.
22 ["q=\"asdf\"", "q=%22asdf%22"],
25 for (var i
= 0; i
< cases
.length
; ++i
) {
26 shouldBe("canonicalize('http://www.example.com/?" + cases
[i
][0] + "')",
27 "'http://www.example.com/?" + cases
[i
][1] + "'");