js/src/tests/ecma_3/extensions/regress-103087.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  * Date: 04 October 2001
     8  *
     9  * SUMMARY:  Arose from Bugzilla bug 103087:
    10  * "The RegExp MarkupSPE in demo crashes Mozilla"
    11  *
    12  * See http://bugzilla.mozilla.org/show_bug.cgi?id=103087
    13  * The SpiderMonkey shell crashed on some of these regexps.
    14  *
    15  * The reported crash was on i=24 below ('MarkupSPE' regexp)
    16  * I crashed on that, and also on i=43 ('XML_SPE' regexp)
    17  */
    18 //-----------------------------------------------------------------------------
    19 var UBound = 0;
    20 var BUGNUMBER = 103087;
    21 var summary = "Testing that we don't crash on any of these regexps -";
    22 var re = '';
    23 var lm = '';
    24 var lc = '';
    25 var rc = '';
    28 // the regexps are built in pieces  -
    29 var NameStrt = "[A-Za-z_:]|[^\\x00-\\x7F]";
    30 var NameChar = "[A-Za-z0-9_:.-]|[^\\x00-\\x7F]";
    31 var Name = "(" + NameStrt + ")(" + NameChar + ")*";
    32 var TextSE = "[^<]+";
    33 var UntilHyphen = "[^-]*-";
    34 var Until2Hyphens = UntilHyphen + "([^-]" + UntilHyphen + ")*-";
    35 var CommentCE = Until2Hyphens + ">?";
    36 var UntilRSBs = "[^]]*]([^]]+])*]+";
    37 var CDATA_CE = UntilRSBs + "([^]>]" + UntilRSBs + ")*>";
    38 var S = "[ \\n\\t\\r]+";
    39 var QuoteSE = '"[^"]' + "*" + '"' + "|'[^']*'";
    40 var DT_IdentSE = S + Name + "(" + S + "(" + Name + "|" + QuoteSE + "))*";
    41 var MarkupDeclCE = "([^]\"'><]+|" + QuoteSE + ")*>";
    42 var S1 = "[\\n\\r\\t ]";
    43 var UntilQMs = "[^?]*\\?+";
    44 var PI_Tail = "\\?>|" + S1 + UntilQMs + "([^>?]" + UntilQMs + ")*>";
    45 var DT_ItemSE = "<(!(--" + Until2Hyphens + ">|[^-]" + MarkupDeclCE + ")|\\?" + Name + "(" + PI_Tail + "))|%" + Name + ";|" + S;
    46 var DocTypeCE = DT_IdentSE + "(" + S + ")?(\\[(" + DT_ItemSE + ")*](" + S + ")?)?>?";
    47 var DeclCE = "--(" + CommentCE + ")?|\\[CDATA\\[(" + CDATA_CE + ")?|DOCTYPE(" + DocTypeCE + ")?";
    48 var PI_CE = Name + "(" + PI_Tail + ")?";
    49 var EndTagCE = Name + "(" + S + ")?>?";
    50 var AttValSE = '"[^<"]' + "*" + '"' + "|'[^<']*'";
    51 var ElemTagCE = Name + "(" + S + Name + "(" + S + ")?=(" + S + ")?(" + AttValSE + "))*(" + S + ")?/?>?";
    52 var MarkupSPE = "<(!(" + DeclCE + ")?|\\?(" + PI_CE + ")?|/(" + EndTagCE + ")?|(" + ElemTagCE + ")?)";
    53 var XML_SPE = TextSE + "|" + MarkupSPE;
    54 var CommentRE = "<!--" + Until2Hyphens + ">";
    55 var CommentSPE = "<!--(" + CommentCE + ")?";
    56 var PI_RE = "<\\?" + Name + "(" + PI_Tail + ")";
    57 var Erroneous_PI_SE = "<\\?[^?]*(\\?[^>]+)*\\?>";
    58 var PI_SPE = "<\\?(" + PI_CE + ")?";
    59 var CDATA_RE = "<!\\[CDATA\\[" + CDATA_CE;
    60 var CDATA_SPE = "<!\\[CDATA\\[(" + CDATA_CE + ")?";
    61 var ElemTagSE = "<(" + NameStrt + ")([^<>\"']+|" + AttValSE + ")*>";
    62 var ElemTagRE = "<" + Name + "(" + S + Name + "(" + S + ")?=(" + S + ")?(" + AttValSE + "))*(" + S + ")?/?>";
    63 var ElemTagSPE = "<" + ElemTagCE;
    64 var EndTagRE = "</" + Name + "(" + S + ")?>";
    65 var EndTagSPE = "</(" + EndTagCE + ")?";
    66 var DocTypeSPE = "<!DOCTYPE(" + DocTypeCE + ")?";
    67 var PERef_APE = "%(" + Name + ";?)?";
    68 var HexPart = "x([0-9a-fA-F]+;?)?";
    69 var NumPart = "#([0-9]+;?|" + HexPart + ")?";
    70 var CGRef_APE = "&(" + Name + ";?|" + NumPart + ")?";
    71 var Text_PE = CGRef_APE + "|[^&]+";
    72 var EntityValue_PE = CGRef_APE + "|" + PERef_APE + "|[^%&]+";
    75 var rePatterns = new Array(AttValSE, CDATA_CE, CDATA_RE, CDATA_SPE, CGRef_APE, CommentCE, CommentRE, CommentSPE, DT_IdentSE, DT_ItemSE, DeclCE, DocTypeCE, DocTypeSPE, ElemTagCE, ElemTagRE, ElemTagSE, ElemTagSPE, EndTagCE, EndTagRE, EndTagSPE, EntityValue_PE, Erroneous_PI_SE, HexPart, MarkupDeclCE, MarkupSPE, Name, NameChar, NameStrt, NumPart, PERef_APE, PI_CE, PI_RE, PI_SPE, PI_Tail, QuoteSE, S, S1, TextSE, Text_PE, Until2Hyphens, UntilHyphen, UntilQMs, UntilRSBs, XML_SPE);
    78 // here's a big string to test the regexps on -
    79 var str = '';
    80 str += '<html xmlns="http://www.w3.org/1999/xhtml"' + '\n';
    81 str += '      xmlns:xlink="http://www.w3.org/XML/XLink/0.9">' + '\n';
    82 str += '  <head><title>Three Namespaces</title></head>' + '\n';
    83 str += '  <body>' + '\n';
    84 str += '    <h1 align="center">An Ellipse and a Rectangle</h1>' + '\n';
    85 str += '    <svg xmlns="http://www.w3.org/Graphics/SVG/SVG-19991203.dtd" ' + '\n';
    86 str += '         width="12cm" height="10cm">' + '\n';
    87 str += '      <ellipse rx="110" ry="130" />' + '\n';
    88 str += '      <rect x="4cm" y="1cm" width="3cm" height="6cm" />' + '\n';
    89 str += '    </svg>' + '\n';
    90 str += '    <p xlink:type="simple" xlink:href="ellipses.html">' + '\n';
    91 str += '      More about ellipses' + '\n';
    92 str += '    </p>' + '\n';
    93 str += '    <p xlink:type="simple" xlink:href="rectangles.html">' + '\n';
    94 str += '      More about rectangles' + '\n';
    95 str += '    </p>' + '\n';
    96 str += '    <hr/>' + '\n';
    97 str += '    <p>Last Modified February 13, 2000</p>    ' + '\n';
    98 str += '  </body>' + '\n';
    99 str += '</html>';
   103 //-----------------------------------------------------------------------------
   104 test();
   105 //-----------------------------------------------------------------------------
   109 function test()
   110 {
   111   enterFunc ('test');
   112   printBugNumber(BUGNUMBER);
   113   printStatus (summary);
   115   for (var i=0; i<rePatterns.length; i++)
   116   {
   117     status = inSection(i);
   118     re = new RegExp(rePatterns[i]);
   120     // Test that we don't crash on any of these -
   121     re.exec(str);
   122     getResults();
   124     // Just for the heck of it, test the current leftContext
   125     re.exec(lc);
   126     getResults();
   128     // Test the current rightContext
   129     re.exec(rc);
   130     getResults();
   131   }
   133   reportCompare('No Crash', 'No Crash', '');
   135   exitFunc ('test');
   136 }
   139 function getResults()
   140 {
   141   lm = RegExp.lastMatch;
   142   lc = RegExp.leftContext;
   143   rc = RegExp.rightContext;
   144 }

mercurial