Debian Codegraph @

js/src/tests/non262/RegExp/regress-122076.js

raw
1 /* -*- indent-tabs-mode: nil; js-indent-level: 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/. */
5
6 /*
7 *
8 * Date: 12 Feb 2002
9 * SUMMARY: Don't crash on invalid regexp literals / \\/ /
10 *
11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=122076
12 * The function checkURL() below sometimes caused a compile-time error:
13 *
14 * SyntaxError: unterminated parenthetical (:
15 *
16 * However, sometimes it would cause a crash instead. The presence of
17 * other functions below is merely fodder to help provoke the crash.
18 * The constant |STRESS| is number of times we'll try to crash on this.
19 *
20 */
21 //-----------------------------------------------------------------------------
22 var BUGNUMBER = 122076;
23 var summary = "Don't crash on invalid regexp literals / \\/ /";
24 var STRESS = 10;
25 var sEval = '';
26
27 printBugNumber(BUGNUMBER);
28 printStatus(summary);
29
30
31 sEval += 'function checkDate()'
32 sEval += '{'
33 sEval += 'return (this.value.search(/^[012]?\d\/[0123]?\d\/[0]\d$/) != -1);'
34 sEval += '}'
35
36 sEval += 'function checkDNSName()'
37 sEval += '{'
38 sEval += ' return (this.value.search(/^([\w\-]+\.)+([\w\-]{2,3})$/) != -1);'
39 sEval += '}'
40
41 sEval += 'function checkEmail()'
42 sEval += '{'
43 sEval += ' return (this.value.search(/^([\w\-]+\.)*[\w\-]+@([\w\-]+\.)+([\w\-]{2,3})$/) != -1);'
44 sEval += '}'
45
46 sEval += 'function checkHostOrIP()'
47 sEval += '{'
48 sEval += ' if (this.value.search(/^([\w\-]+\.)+([\w\-]{2,3})$/) == -1)'
49 sEval += ' return (this.value.search(/^[1-2]?\d{1,2}\.[1-2]?\d{1,2}\.[1-2]?\d{1,2}\.[1-2]?\d{1,2}$/) != -1);'
50 sEval += ' else'
51 sEval += ' return true;'
52 sEval += '}'
53
54 sEval += 'function checkIPAddress()'
55 sEval += '{'
56 sEval += ' return (this.value.search(/^[1-2]?\d{1,2}\.[1-2]?\d{1,2}\.[1-2]?\d{1,2}\.[1-2]?\d{1,2}$/) != -1);'
57 sEval += '}'
58
59 sEval += 'function checkURL()'
60 sEval += '{'
61 sEval += ' return (this.value.search(/^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,4}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\/\*\$+@&#;`~=%!]*)(\.\w{2,})?)*\/?)$/) != -1);'
62 sEval += '}'
63
64
65 for (var i=0; i<STRESS; i++)
66 {
67 try
68 {
69 eval(sEval);
70 }
71 catch(e)
72 {
73 }
74 }
75
76 reportCompare('No Crash', 'No Crash', '');