Debian Codegraph @

rhino/testsrc/tests/ecma_3/RegExp/regress-122076.js

raw symbols SCIP
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/. */
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 gTestfile = 'regress-122076.js';
23 var BUGNUMBER = 122076;
24 var summary = "Don't crash on invalid regexp literals / \\/ /";
25 var STRESS = 10;
26 var sEval = '';
27
28 printBugNumber(BUGNUMBER);
29 printStatus(summary);
30
31
32 sEval += 'function checkDate()'
33 sEval += '{'
34 sEval += 'return (this.value.search(/^[012]?\d\/[0123]?\d\/[0]\d$/) != -1);'
35 sEval += '}'
36
37 sEval += 'function checkDNSName()'
38 sEval += '{'
39 sEval += ' return (this.value.search(/^([\w\-]+\.)+([\w\-]{2,3})$/) != -1);'
40 sEval += '}'
41
42 sEval += 'function checkEmail()'
43 sEval += '{'
44 sEval += ' return (this.value.search(/^([\w\-]+\.)*[\w\-]+@([\w\-]+\.)+([\w\-]{2,3})$/) != -1);'
45 sEval += '}'
46
47 sEval += 'function checkHostOrIP()'
48 sEval += '{'
49 sEval += ' if (this.value.search(/^([\w\-]+\.)+([\w\-]{2,3})$/) == -1)'
50 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);'
51 sEval += ' else'
52 sEval += ' return true;'
53 sEval += '}'
54
55 sEval += 'function checkIPAddress()'
56 sEval += '{'
57 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);'
58 sEval += '}'
59
60 sEval += 'function checkURL()'
61 sEval += '{'
62 sEval += ' return (this.value.search(/^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,4}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\/\*\$+@&#;`~=%!]*)(\.\w{2,})?)*\/?)$/) != -1);'
63 sEval += '}'
64
65
66 for (var i=0; i<STRESS; i++)
67 {
68 try
69 {
70 eval(sEval);
71 }
72 catch(e)
73 {
74 }
75 }
76
77 reportCompare('No Crash', 'No Crash', '');