tor-browser

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

escape-below.js (1438B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-escape-string
      5 es6id: B.2.1.1
      6 description: Escaping of code units below 255
      7 info: |
      8    [...]
      9    5. Repeat, while k < length,
     10       a. Let char be the code unit (represented as a 16-bit unsigned integer)
     11          at index k within string.
     12       [...]
     13       d. Else char < 256,
     14          i. Let S be a String containing three code units "%xy" where xy are
     15             the code units of two uppercase hexadecimal digits encoding the
     16             value of char.
     17       [...]
     18 ---*/
     19 
     20 assert.sameValue(
     21  escape('\x00\x01\x02\x03'),
     22  '%00%01%02%03',
     23  'characters: \\x00\\x01\\x02\\x03'
     24 );
     25 
     26 assert.sameValue(
     27  escape('!"#$%&\'()'),
     28  '%21%22%23%24%25%26%27%28%29',
     29  'characters preceding "*": !"#$%&\'()'
     30 );
     31 
     32 assert.sameValue(escape(','), '%2C', 'character between "+" and "-": ,');
     33 
     34 assert.sameValue(
     35  escape(':;<=>?'),
     36  '%3A%3B%3C%3D%3E%3F',
     37  'characters between "9" and "@": :;<=>?'
     38 );
     39 
     40 assert.sameValue(
     41  escape('[\\]^'), '%5B%5C%5D%5E', 'characters between "Z" and "_": [\\]^'
     42 );
     43 
     44 assert.sameValue(escape('`'), '%60', 'character between "_" and "a": `');
     45 
     46 assert.sameValue(
     47  escape('{|}~\x7f\x80'),
     48  '%7B%7C%7D%7E%7F%80',
     49  'characters following "z": {|}~\\x7f\\x80'
     50 );
     51 
     52 assert.sameValue(
     53  escape('\xfd\xfe\xff'), '%FD%FE%FF', '\\xfd\\xfe\\xff'
     54 );
     55 
     56 reportCompare(0, 0);