michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * michael@0: * Date: 12 Feb 2002 michael@0: * SUMMARY: Don't crash on invalid regexp literals / \\/ / michael@0: * michael@0: * See http://bugzilla.mozilla.org/show_bug.cgi?id=122076 michael@0: * The function checkURL() below sometimes caused a compile-time error: michael@0: * michael@0: * SyntaxError: unterminated parenthetical (: michael@0: * michael@0: * However, sometimes it would cause a crash instead. The presence of michael@0: * other functions below is merely fodder to help provoke the crash. michael@0: * The constant |STRESS| is number of times we'll try to crash on this. michael@0: * michael@0: */ michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 122076; michael@0: var summary = "Don't crash on invalid regexp literals / \\/ /"; michael@0: var STRESS = 10; michael@0: var sEval = ''; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus(summary); michael@0: michael@0: michael@0: sEval += 'function checkDate()' michael@0: sEval += '{' michael@0: sEval += 'return (this.value.search(/^[012]?\d\/[0123]?\d\/[0]\d$/) != -1);' michael@0: sEval += '}' michael@0: michael@0: sEval += 'function checkDNSName()' michael@0: sEval += '{' michael@0: sEval += ' return (this.value.search(/^([\w\-]+\.)+([\w\-]{2,3})$/) != -1);' michael@0: sEval += '}' michael@0: michael@0: sEval += 'function checkEmail()' michael@0: sEval += '{' michael@0: sEval += ' return (this.value.search(/^([\w\-]+\.)*[\w\-]+@([\w\-]+\.)+([\w\-]{2,3})$/) != -1);' michael@0: sEval += '}' michael@0: michael@0: sEval += 'function checkHostOrIP()' michael@0: sEval += '{' michael@0: sEval += ' if (this.value.search(/^([\w\-]+\.)+([\w\-]{2,3})$/) == -1)' michael@0: 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);' michael@0: sEval += ' else' michael@0: sEval += ' return true;' michael@0: sEval += '}' michael@0: michael@0: sEval += 'function checkIPAddress()' michael@0: sEval += '{' michael@0: 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);' michael@0: sEval += '}' michael@0: michael@0: sEval += 'function checkURL()' michael@0: sEval += '{' michael@0: sEval += ' return (this.value.search(/^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,4}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\/\*\$+@&#;`~=%!]*)(\.\w{2,})?)*\/?)$/) != -1);' michael@0: sEval += '}' michael@0: michael@0: michael@0: for (var i=0; i