Bug 1386683 - Do not escape the `'` character in the URL hash r=junior draft
authorValentin Gosu <valentin.gosu@gmail.com>
Sun, 06 Aug 2017 11:13:04 +0200
changeset 641211 22de804e82136114a0688ce271cac8c49f8c4f23
parent 619065 ef9a0f01e4f68214f0ff8f4631783b8a0e075a82
child 724751 3c5fb40fd8b750a4a5fec13e0aec0222d4d0cd03
push id72476
push uservalentin.gosu@gmail.com
push dateSun, 06 Aug 2017 10:10:34 +0000
reviewersjunior
bugs1386683
milestone56.0a1
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
 };