Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | const ONLY_NONASCII = Components.interfaces.nsINetUtil.ESCAPE_URL_ONLY_NONASCII; |
michael@0 | 2 | const SKIP_CONTROL = Components.interfaces.nsINetUtil.ESCAPE_URL_SKIP_CONTROL; |
michael@0 | 3 | |
michael@0 | 4 | |
michael@0 | 5 | var tests = [ |
michael@0 | 6 | ["foo", "foo", 0], |
michael@0 | 7 | ["foo%20bar", "foo bar", 0], |
michael@0 | 8 | ["foo%2zbar", "foo%2zbar", 0], |
michael@0 | 9 | ["foo%", "foo%", 0], |
michael@0 | 10 | ["%zzfoo", "%zzfoo", 0], |
michael@0 | 11 | ["foo%z", "foo%z", 0], |
michael@0 | 12 | ["foo%00bar", "foo\x00bar", 0], |
michael@0 | 13 | ["foo%ffbar", "foo\xffbar", 0], |
michael@0 | 14 | ["%00%1b%20%61%7f%80%ff", "%00%1b%20%61%7f\x80\xff", ONLY_NONASCII], |
michael@0 | 15 | ["%00%1b%20%61%7f%80%ff", "%00%1b a%7f\x80\xff", SKIP_CONTROL], |
michael@0 | 16 | ["%00%1b%20%61%7f%80%ff", "%00%1b%20%61%7f\x80\xff", ONLY_NONASCII|SKIP_CONTROL], |
michael@0 | 17 | // Test that we do not drop the high-bytes of a UTF-16 string. |
michael@0 | 18 | ["\u30a8\u30c9", "\xe3\x82\xa8\xe3\x83\x89", 0], |
michael@0 | 19 | ]; |
michael@0 | 20 | |
michael@0 | 21 | function run_test() { |
michael@0 | 22 | var util = Components.classes["@mozilla.org/network/util;1"] |
michael@0 | 23 | .getService(Components.interfaces.nsINetUtil); |
michael@0 | 24 | |
michael@0 | 25 | for (var i = 0; i < tests.length; ++i) { |
michael@0 | 26 | dump("Test " + i + " (" + tests[i][0] + ", " + tests[i][2] + ")\n"); |
michael@0 | 27 | do_check_eq(util.unescapeString(tests[i][0], tests[i][2]), |
michael@0 | 28 | tests[i][1]); |
michael@0 | 29 | } |
michael@0 | 30 | dump(tests.length + " tests passed\n"); |
michael@0 | 31 | } |