tor-browser

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

ambiguous-ampersand.html (1438B)


      1 <!DOCTYPE html>
      2 <meta charset="UTF-8">
      3 <title>Ambiguous ampersand</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <div><a href='?a=b&c=d&a0b=c&copy=1&noti=n&not=in&notin=&notin;&not;&;& &'>Link</a><p>Text: ?a=b&c=d&a0b=c&copy=1&noti=n&not=in&notin=&notin;&not;&;& &</p></div>
      7 <script>
      8 var markup = "<div><a href='?a=b&c=d&a0b=c&copy=1&noti=n&not=in&notin=&notin;&not;&;& &'>Link</a><p>Text: ?a=b&c=d&a0b=c&copy=1&noti=n&not=in&notin=&notin;&not;&;& &</p></div>";
      9 
     10 for (var i = 0; i < markup.length; ++i) {
     11    document.write(markup.charAt(i));
     12 }
     13 </script>
     14 
     15 <script>
     16 function checkDiv(div, provenance) {
     17    test(function() {
     18        assert_equals(div.childNodes.length, 2, "Number of elements " + provenance);
     19        let a = div.firstChild;
     20        let href = a.href;
     21        let question = href.indexOf('?');
     22        href = href.substring(question);
     23        assert_equals(href, "?a=b&c=d&a0b=c&copy=1&noti=n&not=in&notin=%E2%88%89%C2%AC&;&%20&", "attribute " + provenance);
     24        let p = a.nextSibling;
     25        assert_equals(p.textContent, "Text: ?a=b&c=d&a0b=c©=1¬i=n¬=in¬in=∉¬&;& &", "text " + provenance)
     26    }, "Check div structure: " + provenance);
     27 }
     28 
     29 
     30 let divs = document.getElementsByTagName("div");
     31 test(function() {
     32    assert_equals(divs.length, 2);
     33 }, "Check number of divs");
     34 checkDiv(divs[0], "network");
     35 checkDiv(divs[1], "document.write");
     36 </script>