tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

lone-surrogates.sub.html (1004B)


      1 <!doctype html>
      2 <meta charset={{GET[encoding]}}> <!-- ends up as <meta charset> by default which is windows-1252 -->
      3 <meta name=variant content="?encoding=windows-1252">
      4 <meta name=variant content="?encoding=utf8">
      5 <script src=/resources/testharness.js></script>
      6 <script src=/resources/testharnessreport.js></script>
      7 <div id=log></div>
      8 <script>
      9 function expected(encoding) {
     10  return "?" + {
     11    // Replacement character (not bogus UTF-8)
     12    "UTF-8": "%EF%BF%BD",
     13    // Charref for the replacement character (not the lone surrogate)
     14    "windows-1252": "%26%2365533%3B",
     15  }[encoding];
     16 }
     17 
     18 test(t => {
     19  const elm = document.createElement("a");
     20  document.body.appendChild(elm);
     21  t.add_cleanup(() => elm.remove());
     22  elm.setAttribute("href", "?\uD800");
     23 
     24  const shouldEndWith = expected(document.characterSet);
     25  assert_true(
     26    elm.href.endsWith(shouldEndWith),
     27    `${elm.href} did not end with ${shouldEndWith}`
     28  );
     29 }, `Query parsing with lone surrogates in ${document.characterSet}`);
     30 </script>