tor-browser

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

unicode_restricted_identity_escape_c.js (1426B)


      1 // Copyright (C) 2015 André Bargull. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: B.1.4 is not applied for Unicode RegExp - Invalid control escape sequences
      6 info: |
      7    The compatibility extensions defined in B.1.4 Regular Expressions Patterns
      8    are not applied for Unicode RegExp.
      9    Tested extension: "IdentityEscape[U] :: [~U] SourceCharacter but not c"
     10 es6id: 21.1.2
     11 ---*/
     12 
     13 function isAlpha(c) {
     14  return ("A" <= c && c <= "Z") || ("a" <= c && c <= "z");
     15 }
     16 
     17 
     18 // "c ControlLetter" sequence in AtomEscape.
     19 //
     20 // AtomEscape[U] :: CharacterEscape[?U]
     21 // CharacterEscape[U] :: c ControlLetter
     22 assert.throws(SyntaxError, function() { RegExp("\\c", "u"); });
     23 for (var cu = 0x00; cu <= 0x7f; ++cu) {
     24  var s = String.fromCharCode(cu);
     25  if (!isAlpha(s)) {
     26    assert.throws(SyntaxError, function() {
     27      RegExp("\\c" + s, "u");
     28    }, "ControlLetter escape in AtomEscape: '" + s + "'");
     29  }
     30 }
     31 
     32 
     33 // "c ControlLetter" sequence in ClassEscape.
     34 //
     35 // ClassEscape[U] :: CharacterEscape[?U]
     36 // CharacterEscape[U] :: c ControlLetter
     37 assert.throws(SyntaxError, function() { RegExp("[\\c]", "u"); });
     38 for (var cu = 0x00; cu <= 0x7f; ++cu) {
     39  var s = String.fromCharCode(cu);
     40  if (!isAlpha(s)) {
     41    assert.throws(SyntaxError, function() {
     42      RegExp("[\\c" + s + "]", "u");
     43    }, "ControlLetter escape in ClassEscape: '" + s + "'");
     44  }
     45 }
     46 
     47 reportCompare(0, 0);