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/. */
9
* SUMMARY: Don't crash on invalid regexp literals / \\/ /
11
* See http://bugzilla.mozilla.org/show_bug.cgi?id=122076
12
* The function checkURL() below sometimes caused a compile-time error:
14
* SyntaxError: unterminated parenthetical (:
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.
21
//-----------------------------------------------------------------------------
22
var BUGNUMBER = 122076;
23
var summary = "Don't crash on invalid regexp literals / \\/ /";
27
printBugNumber(BUGNUMBER);
31
sEval += 'function checkDate()'
33
sEval += 'return (this.value.search(/^[012]?\d\/[0123]?\d\/[0]\d$/) != -1);'
36
sEval += 'function checkDNSName()'
38
sEval += ' return (this.value.search(/^([\w\-]+\.)+([\w\-]{2,3})$/) != -1);'
41
sEval += 'function checkEmail()'
43
sEval += ' return (this.value.search(/^([\w\-]+\.)*[\w\-]+@([\w\-]+\.)+([\w\-]{2,3})$/) != -1);'
46
sEval += 'function checkHostOrIP()'
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);'
51
sEval += ' return true;'
54
sEval += 'function checkIPAddress()'
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);'
59
sEval += 'function checkURL()'
61
sEval += ' return (this.value.search(/^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,4}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\/\*\$+@&#;`~=%!]*)(\.\w{2,})?)*\/?)$/) != -1);'
65
for (var i=0; i<STRESS; i++)
76
reportCompare('No Crash', 'No Crash', '');