js/src/tests/ecma_3/RegExp/regress-119909.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 /*
     7  *
     8  * Date:    14 Jan 2002
     9  * SUMMARY: Shouldn't crash on regexps with many nested parentheses
    10  * See http://bugzilla.mozilla.org/show_bug.cgi?id=119909
    11  *
    12  */
    13 //-----------------------------------------------------------------------------
    14 var BUGNUMBER = 119909;
    15 var summary = "Shouldn't crash on regexps with many nested parentheses";
    16 var NO_BACKREFS = false;
    17 var DO_BACKREFS = true;
    20 //--------------------------------------------------
    21 test();
    22 //--------------------------------------------------
    25 function test()
    26 {
    27   enterFunc('test');
    28   printBugNumber(BUGNUMBER);
    29   printStatus(summary);
    31   testThis(500, NO_BACKREFS, 'hello', 'goodbye');
    32   testThis(500, DO_BACKREFS, 'hello', 'goodbye');
    34   reportCompare('No Crash', 'No Crash', '');
    36   exitFunc('test');
    37 }
    40 /*
    41  * Creates a regexp pattern like (((((((((hello)))))))))
    42  * and tests str.search(), str.match(), str.replace()
    43  */
    44 function testThis(numParens, doBackRefs, strOriginal, strReplace)
    45 {
    46   var openParen = doBackRefs? '(' : '(?:';
    47   var closeParen = ')';
    48   var pattern = '';
    50   for (var i=0; i<numParens; i++) {pattern += openParen;}
    51   pattern += strOriginal;
    52   for (i=0; i<numParens; i++) {pattern += closeParen;}
    53   var re = new RegExp(pattern);
    55   var res = strOriginal.search(re);
    56   res = strOriginal.match(re);
    57   res = strOriginal.replace(re, strReplace);
    58 }

mercurial