| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'regress-330569.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 330569; |
| 9 |
var summary = 'RegExp - throw InternalError on too complex regular expressions'; |
| 10 |
var actual = ''; |
| 11 |
var expect = ''; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
test(); |
| 16 |
|
| 17 |
|
| 18 |
function test() |
| 19 |
{ |
| 20 |
enterFunc ('test'); |
| 21 |
printBugNumber(BUGNUMBER); |
| 22 |
printStatus (summary); |
| 23 |
|
| 24 |
var s; |
| 25 |
expect = 'InternalError: regular expression too complex'; |
| 26 |
|
| 27 |
s = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' + |
| 28 |
'<html>\n' + |
| 29 |
'<head>\n' + |
| 30 |
'<meta http-equiv="content-type" content="text/html; charset=windows-1250">\n' + |
| 31 |
'<meta name="generator" content="PSPad editor, www.pspad.com">\n' + |
| 32 |
'<title></title>\n'+ |
| 33 |
'</head>\n' + |
| 34 |
'<body>\n' + |
| 35 |
'<!-- hello -->\n' + |
| 36 |
'<script language="JavaScript">\n' + |
| 37 |
'var s = document. body. innerHTML;\n' + |
| 38 |
'var d = s. replace (/<!--(.*|\n)*-->/, "");\n' + |
| 39 |
'alert (d);\n' + |
| 40 |
'</script>\n' + |
| 41 |
'</body>\n' + |
| 42 |
'</html>\n'; |
| 43 |
|
| 44 |
options('relimit'); |
| 45 |
|
| 46 |
try |
| 47 |
{ |
| 48 |
/<!--(.*|\n)*-->/.exec(s); |
| 49 |
} |
| 50 |
catch(ex) |
| 51 |
{ |
| 52 |
actual = ex + ''; |
| 53 |
} |
| 54 |
|
| 55 |
reportCompare(expect, actual, summary + ': /<!--(.*|\\n)*-->/.exec(s)'); |
| 56 |
|
| 57 |
function testre( re, n ) { |
| 58 |
for ( var i= 0; i <= n; ++i ) { |
| 59 |
re.test( Array( i+1 ).join() ); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
try |
| 64 |
{ |
| 65 |
testre( /(?:,*)*x/, 22 ); |
| 66 |
} |
| 67 |
catch(ex) |
| 68 |
{ |
| 69 |
actual = ex + ''; |
| 70 |
} |
| 71 |
|
| 72 |
reportCompare(expect, actual, summary + ': testre( /(?:,*)*x/, 22 )'); |
| 73 |
|
| 74 |
try |
| 75 |
{ |
| 76 |
testre( /(?:,|,)*x/, 22 ); |
| 77 |
} |
| 78 |
catch(ex) |
| 79 |
{ |
| 80 |
actual = ex + ''; |
| 81 |
} |
| 82 |
|
| 83 |
reportCompare(expect, actual, summary + ': testre( /(?:,|,)*x/, 22 )'); |
| 84 |
|
| 85 |
try |
| 86 |
{ |
| 87 |
testre( /(?:,|,|,|,|,)*x/, 10 ); |
| 88 |
} |
| 89 |
catch(ex) |
| 90 |
{ |
| 91 |
actual = ex + ''; |
| 92 |
} |
| 93 |
reportCompare(expect, actual, summary + ': testre( /(?:,|,|,|,|,)*x/, 10 )'); |
| 94 |
|
| 95 |
exitFunc ('test'); |
| 96 |
} |