From e96a491a5d48c8d6fc43daef8bb5f8a72b3e59b9 Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Mon, 2 Nov 2015 13:54:10 +0100 Subject: [PATCH] Bug 1163028 - URL: stop escaping [ and ] in path r=mcmanus --- netwerk/test/unit/test_standardurl.js | 13 +++++++++++-- xpcom/io/nsEscape.cpp | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/netwerk/test/unit/test_standardurl.js b/netwerk/test/unit/test_standardurl.js index 9c8c8ec12787..aa0ef50c19a0 100644 --- a/netwerk/test/unit/test_standardurl.js +++ b/netwerk/test/unit/test_standardurl.js @@ -220,8 +220,9 @@ function test_clearedSpec() symmetricEquality(true, url, ref); } -function test_escapeQueryBrackets() +function test_escapeBrackets() { + // Query var url = stringToURL("http://example.com/?a[x]=1"); do_check_eq(url.spec, "http://example.com/?a[x]=1"); @@ -233,6 +234,14 @@ function test_escapeQueryBrackets() url = stringToURL("http://[2001::1]/?a%5Bx%5D=1"); do_check_eq(url.spec, "http://[2001::1]/?a%5Bx%5D=1"); + + // Path + url = stringToURL("http://example.com/brackets[x]/test"); + do_check_eq(url.spec, "http://example.com/brackets[x]/test"); + + url = stringToURL("http://example.com/a%5Bx%5D/test"); + do_check_eq(url.spec, "http://example.com/a%5Bx%5D/test"); + } function test_apostropheEncoding() @@ -251,6 +260,6 @@ function run_test() test_ipv6(); test_ipv6_fail(); test_clearedSpec(); - test_escapeQueryBrackets(); + test_escapeBrackets(); test_apostropheEncoding(); } diff --git a/xpcom/io/nsEscape.cpp b/xpcom/io/nsEscape.cpp index b5145932c575..a24909f08176 100644 --- a/xpcom/io/nsEscape.cpp +++ b/xpcom/io/nsEscape.cpp @@ -360,7 +360,7 @@ static const uint32_t EscapeChars[256] = 0,1023, 0, 512,1023, 0,1023, 112,1023,1023,1023,1023,1023,1023, 953, 784, // 2x !"#$%&'()*+,-./ 1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1008,1008, 0,1008, 0, 768, // 3x 0123456789:;<=>? 1008,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, // 4x @ABCDEFGHIJKLMNO - 1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, 896, 896, 896, 896,1023, // 5x PQRSTUVWXYZ[\]^_ + 1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1008, 896,1008, 896,1023, // 5x PQRSTUVWXYZ[\]^_ 0,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, // 6x `abcdefghijklmno 1023,1023,1023,1023,1023,1023,1023,1023,1023,1023,1023, 896,1012, 896,1023, 0, // 7x pqrstuvwxyz{|}~ DEL 0 // 80 to FF are zero