~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/tests/ecma_3/RegExp/regress-122076.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 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', '');