Bug 1386683 - Do not escape the `'` character in the URL hash r=junior
authorValentin Gosu <valentin.gosu@gmail.com>
Sun, 06 Aug 2017 11:13:04 +0200
changeset 373857 bcf82372275b79f5b1e440b24490fc7f3a1f8f7e
parent 373856 a5622f42070ba521db3bc43ca5b2446664b7c959
child 373858 4fa607fc5f7ec219e24ee34999494d59ca39f004
push id32309
push userkwierso@gmail.com
push dateFri, 11 Aug 2017 00:36:58 +0000
treeherdermozilla-central@d0068f9051be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjunior
bugs1386683
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1386683 - Do not escape the `'` character in the URL hash r=junior MozReview-Commit-ID: DkoDvWGbWfu
netwerk/test/unit/test_standardurl.js
xpcom/io/nsEscape.cpp
--- a/netwerk/test/unit/test_standardurl.js
+++ b/netwerk/test/unit/test_standardurl.js
@@ -247,16 +247,27 @@ add_test(function test_escapeBrackets()
   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");
   run_next_test();
 });
 
+add_test(function test_escapeQuote()
+{
+  var url = stringToURL("http://example.com/#'");
+  do_check_eq(url.spec, "http://example.com/#'");
+  do_check_eq(url.ref, "'");
+  url.ref = "test'test";
+  do_check_eq(url.spec, "http://example.com/#test'test");
+  do_check_eq(url.ref, "test'test");
+  run_next_test();
+});
+
 add_test(function test_apostropheEncoding()
 {
   // For now, single quote is escaped everywhere _except_ the path.
   // This policy is controlled by the bitmask in nsEscape.cpp::EscapeChars[]
   var url = stringToURL("http://example.com/dir'/file'.ext'");
   do_check_eq(url.spec, "http://example.com/dir'/file'.ext'");
   run_next_test();
 });
--- a/xpcom/io/nsEscape.cpp
+++ b/xpcom/io/nsEscape.cpp
@@ -341,17 +341,17 @@ nsEscapeHTML2(const char16_t* aSourceBuf
 // esc_Query         =   256
 // esc_Ref           =   512
 
 static const uint32_t EscapeChars[256] =
 //   0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F
 {
      0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  // 0x
      0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  // 1x
-     0,1023,   0, 512,1023,   0,1023, 112,1023,1023,1023,1023,1023,1023, 953, 784,  // 2x   !"#$%&'()*+,-./
+     0,1023,   0, 512,1023,   0,1023, 624,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,1008, 896,1008, 896,1023,  // 5x  PQRSTUVWXYZ[\]^_
    384,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
 };