tor-browser

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

urlencoded-parser.any.js (3014B)


      1 [
      2  { "input": "test", "output": [["test", ""]] },
      3  { "input": "\uFEFFtest=\uFEFF", "output": [["\uFEFFtest", "\uFEFF"]] },
      4  { "input": "%EF%BB%BFtest=%EF%BB%BF", "output": [["\uFEFFtest", "\uFEFF"]] },
      5  { "input": "%EF%BF%BF=%EF%BF%BF", "output": [["\uFFFF", "\uFFFF"]] },
      6  { "input": "%FE%FF", "output": [["\uFFFD\uFFFD", ""]] },
      7  { "input": "%FF%FE", "output": [["\uFFFD\uFFFD", ""]] },
      8  { "input": "†&†=x", "output": [["†", ""], ["†", "x"]] },
      9  { "input": "%C2", "output": [["\uFFFD", ""]] },
     10  { "input": "%C2x", "output": [["\uFFFDx", ""]] },
     11  { "input": "_charset_=windows-1252&test=%C2x", "output": [["_charset_", "windows-1252"], ["test", "\uFFFDx"]] },
     12  { "input": '', "output": [] },
     13  { "input": 'a', "output": [['a', '']] },
     14  { "input": 'a=b', "output": [['a', 'b']] },
     15  { "input": 'a=', "output": [['a', '']] },
     16  { "input": '=b', "output": [['', 'b']] },
     17  { "input": '&', "output": [] },
     18  { "input": '&a', "output": [['a', '']] },
     19  { "input": 'a&', "output": [['a', '']] },
     20  { "input": 'a&a', "output": [['a', ''], ['a', '']] },
     21  { "input": 'a&b&c', "output": [['a', ''], ['b', ''], ['c', '']] },
     22  { "input": 'a=b&c=d', "output": [['a', 'b'], ['c', 'd']] },
     23  { "input": 'a=b&c=d&', "output": [['a', 'b'], ['c', 'd']] },
     24  { "input": '&&&a=b&&&&c=d&', "output": [['a', 'b'], ['c', 'd']] },
     25  { "input": 'a=a&a=b&a=c', "output": [['a', 'a'], ['a', 'b'], ['a', 'c']] },
     26  { "input": 'a==a', "output": [['a', '=a']] },
     27  { "input": 'a=a+b+c+d', "output": [['a', 'a b c d']] },
     28  { "input": '%=a', "output": [['%', 'a']] },
     29  { "input": '%a=a', "output": [['%a', 'a']] },
     30  { "input": '%a_=a', "output": [['%a_', 'a']] },
     31  { "input": '%61=a', "output": [['a', 'a']] },
     32  { "input": '%61+%4d%4D=', "output": [['a MM', '']] },
     33  { "input": "id=0&value=%", "output": [['id', '0'], ['value', '%']] },
     34  { "input": "b=%2sf%2a", "output": [['b', '%2sf*']]},
     35  { "input": "b=%2%2af%2a", "output": [['b', '%2*f*']]},
     36  { "input": "b=%%2a", "output": [['b', '%*']]}
     37 ].forEach((val) => {
     38  test(() => {
     39    let sp = new URLSearchParams(val.input),
     40        i = 0
     41    for (let item of sp) {
     42       assert_array_equals(item, val.output[i])
     43       i++
     44    }
     45  }, "URLSearchParams constructed with: " + val.input)
     46 
     47  promise_test(() => {
     48    let init = new Request("about:blank", { body: val.input, method: "LADIDA", headers: {"Content-Type": "application/x-www-form-urlencoded;charset=windows-1252"} }).formData()
     49    return init.then((fd) => {
     50      let i = 0
     51      for (let item of fd) {
     52         assert_array_equals(item, val.output[i])
     53         i++
     54      }
     55    })
     56  }, "request.formData() with input: " + val.input)
     57 
     58  promise_test(() => {
     59    let init = new Response(val.input, { headers: {"Content-Type": "application/x-www-form-urlencoded;charset=shift_jis"} }).formData()
     60    return init.then((fd) => {
     61      let i = 0
     62      for (let item of fd) {
     63         assert_array_equals(item, val.output[i])
     64         i++
     65      }
     66    })
     67  }, "response.formData() with input: " + val.input)
     68 });