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.

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

mercurial