tor-browser

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

headers-normalize-response.htm (1404B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Whitespace and null in header values</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <div id=log></div>
      7 <script>
      8 function error(val) {
      9  test(() => {
     10    const client = new XMLHttpRequest();
     11    client.open("GET", "resources/parse-headers.py?my-custom-header="+encodeURIComponent(val), false);
     12    assert_throws_dom("NetworkError", () => client.send());
     13  }, "Header value: " + val.replace("\0", "\\0"));
     14 }
     15 
     16 function matchHeaderValue(val) {
     17    test(function () {
     18        var client = new XMLHttpRequest();
     19        var trimmed = val.trim();
     20        client.open("GET", "resources/parse-headers.py?my-custom-header="+encodeURIComponent(val), false);
     21        client.send();
     22        var r = client.getResponseHeader("My-Custom-Header");
     23 
     24        assert_equals(r, trimmed);
     25    }, "Header value: " + val.replace(/\t/g, "[tab]").replace(/ /g, "_"));
     26 }
     27 
     28 error("hello world\0");
     29 error("\0hello world");
     30 error("hello\0world");
     31 matchHeaderValue("  hello world");
     32 matchHeaderValue("hello world  ");
     33 matchHeaderValue("  hello world  ");
     34 matchHeaderValue("\thello world");
     35 matchHeaderValue("hello world\t");
     36 matchHeaderValue("\thello world\t");
     37 matchHeaderValue("hello      world");
     38 matchHeaderValue("hello\tworld");
     39 error("\0");
     40 matchHeaderValue("   ");
     41 matchHeaderValue("\t");
     42 matchHeaderValue("");
     43 </script>