diff --git a/mozilla/netwerk/base/public/nsINetUtil.idl b/mozilla/netwerk/base/public/nsINetUtil.idl index 8e41c692b59..26cda864569 100644 --- a/mozilla/netwerk/base/public/nsINetUtil.idl +++ b/mozilla/netwerk/base/public/nsINetUtil.idl @@ -161,7 +161,7 @@ interface nsINetUtil : nsISupports /** * Skip graphic octets (0x20-0x7E) when escaping - * Skips all ascii octets when unescaping + * Skips all ASCII octets (0x00-0x7F) when unescaping */ const unsigned long ESCAPE_URL_ONLY_NONASCII = 1 << 12; diff --git a/mozilla/netwerk/test/unit/test_unescapestring.js b/mozilla/netwerk/test/unit/test_unescapestring.js new file mode 100644 index 00000000000..7fb638e277c --- /dev/null +++ b/mozilla/netwerk/test/unit/test_unescapestring.js @@ -0,0 +1,29 @@ +const ONLY_NONASCII = Components.interfaces.nsINetUtil.ESCAPE_URL_ONLY_NONASCII; +const SKIP_CONTROL = Components.interfaces.nsINetUtil.ESCAPE_URL_SKIP_CONTROL; + + +var tests = [ + ["foo", "foo", 0], + ["foo%20bar", "foo bar", 0], + ["foo%2zbar", "foo%2zbar", 0], + ["foo%", "foo%", 0], + ["%zzfoo", "%zzfoo", 0], + ["foo%z", "foo%z", 0], + ["foo%00bar", "foo\x00bar", 0], + ["foo%ffbar", "foo\xffbar", 0], + ["%00%1b%20%61%7f%80%ff", "%00%1b%20%61%7f\x80\xff", ONLY_NONASCII], + ["%00%1b%20%61%7f%80%ff", "%00%1b a%7f\x80\xff", SKIP_CONTROL], + ["%00%1b%20%61%7f%80%ff", "%00%1b%20%61%7f\x80\xff", ONLY_NONASCII|SKIP_CONTROL] +]; + +function run_test() { + var util = Components.classes["@mozilla.org/network/util;1"] + .getService(Components.interfaces.nsINetUtil); + + for (var i = 0; i < tests.length; ++i) { + dump("Test " + i + " (" + tests[i][0] + ", " + tests[i][2] + ")\n"); + do_check_eq(util.unescapeString(tests[i][0], tests[i][2]), + tests[i][1]); + } + dump(tests.length + " tests passed\n"); +} diff --git a/mozilla/xpcom/io/nsEscape.h b/mozilla/xpcom/io/nsEscape.h index dece84ed013..c57739db94d 100644 --- a/mozilla/xpcom/io/nsEscape.h +++ b/mozilla/xpcom/io/nsEscape.h @@ -122,7 +122,7 @@ enum EscapeMask { esc_OnlyASCII = PR_BIT(11), /* causes non-ascii octets to be skipped */ esc_OnlyNonASCII = PR_BIT(12), /* causes _graphic_ ascii octets (0x20-0x7E) * to be skipped when escaping. causes all - * ascii octets to be skipped when unescaping */ + * ascii octets (<= 0x7F) to be skipped when unescaping */ esc_AlwaysCopy = PR_BIT(13), /* copy input to result buf even if escaping is unnecessary */ esc_Colon = PR_BIT(14), /* forces escape of colon */ esc_SkipControl = PR_BIT(15) /* skips C0 and DEL from unescaping */