mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out 8ae5fce0f19b.
This commit is contained in:
parent
0cc4fbc8f7
commit
8a45dd1cea
@ -1,43 +0,0 @@
|
|||||||
// Check that builtin character classes within ranges produce syntax
|
|
||||||
// errors.
|
|
||||||
|
|
||||||
function isRegExpSyntaxError(pattern) {
|
|
||||||
try {
|
|
||||||
var re = new RegExp(pattern);
|
|
||||||
} catch (e) {
|
|
||||||
if (e instanceof SyntaxError)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function testRangeSyntax(end1, end2, shouldFail) {
|
|
||||||
var makePattern = function(e1, e2) {
|
|
||||||
var pattern = '[' + e1 + '-' + e2 + ']';
|
|
||||||
print(uneval(pattern));
|
|
||||||
return pattern;
|
|
||||||
};
|
|
||||||
assertEq(isRegExpSyntaxError(makePattern(end1, end2)), shouldFail);
|
|
||||||
assertEq(isRegExpSyntaxError(makePattern(end2, end1)), shouldFail);
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkRangeValid(end1, end2) {
|
|
||||||
testRangeSyntax(end1, end2, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkRangeInvalid(end1, end2) {
|
|
||||||
testRangeSyntax(end1, end2, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
checkRangeInvalid('C', '\\s');
|
|
||||||
checkRangeInvalid('C', '\\d');
|
|
||||||
checkRangeInvalid('C', '\\W');
|
|
||||||
checkRangeInvalid('C', '\\W');
|
|
||||||
checkRangeValid('C', '');
|
|
||||||
checkRangeValid('C', 'C');
|
|
||||||
checkRangeInvalid('\\s', '\\s');
|
|
||||||
checkRangeInvalid('\\W', '\\s');
|
|
||||||
checkRangeValid('\\b', '\\b');
|
|
||||||
checkRangeValid('\\B', '\\B');
|
|
||||||
checkRangeInvalid('\\w', '\\B');
|
|
||||||
checkRangeInvalid('\\w', '\\b');
|
|
@ -58,8 +58,6 @@
|
|||||||
#include "jsobjinlines.h"
|
#include "jsobjinlines.h"
|
||||||
#include "jsregexpinlines.h"
|
#include "jsregexpinlines.h"
|
||||||
|
|
||||||
#include "yarr/RegexParser.h"
|
|
||||||
|
|
||||||
#ifdef JS_TRACER
|
#ifdef JS_TRACER
|
||||||
#include "jstracer.h"
|
#include "jstracer.h"
|
||||||
using namespace avmplus;
|
using namespace avmplus;
|
||||||
@ -173,12 +171,26 @@ js_ObjectIsRegExp(JSObject *obj)
|
|||||||
void
|
void
|
||||||
RegExp::handleYarrError(JSContext *cx, int error)
|
RegExp::handleYarrError(JSContext *cx, int error)
|
||||||
{
|
{
|
||||||
|
/* Hack: duplicated from yarr/yarr/RegexParser.h */
|
||||||
|
enum ErrorCode {
|
||||||
|
NoError,
|
||||||
|
PatternTooLarge,
|
||||||
|
QuantifierOutOfOrder,
|
||||||
|
QuantifierWithoutAtom,
|
||||||
|
MissingParentheses,
|
||||||
|
ParenthesesUnmatched,
|
||||||
|
ParenthesesTypeInvalid, /* "(?" with bad next char or end of pattern. */
|
||||||
|
CharacterClassUnmatched,
|
||||||
|
CharacterClassOutOfOrder,
|
||||||
|
QuantifierTooLarge,
|
||||||
|
EscapeUnterminated
|
||||||
|
};
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case JSC::Yarr::NoError:
|
case NoError:
|
||||||
JS_NOT_REACHED("Precondition violation: an error must have occurred.");
|
JS_NOT_REACHED("Precondition violation: an error must have occurred.");
|
||||||
return;
|
return;
|
||||||
#define COMPILE_EMSG(__code, __msg) \
|
#define COMPILE_EMSG(__code, __msg) \
|
||||||
case JSC::Yarr::__code: \
|
case __code: \
|
||||||
JS_ReportErrorFlagsAndNumberUC(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL, __msg); \
|
JS_ReportErrorFlagsAndNumberUC(cx, JSREPORT_ERROR, js_GetErrorMessage, NULL, __msg); \
|
||||||
return
|
return
|
||||||
COMPILE_EMSG(PatternTooLarge, JSMSG_REGEXP_TOO_COMPLEX);
|
COMPILE_EMSG(PatternTooLarge, JSMSG_REGEXP_TOO_COMPLEX);
|
||||||
@ -186,10 +198,9 @@ RegExp::handleYarrError(JSContext *cx, int error)
|
|||||||
COMPILE_EMSG(QuantifierWithoutAtom, JSMSG_BAD_QUANTIFIER);
|
COMPILE_EMSG(QuantifierWithoutAtom, JSMSG_BAD_QUANTIFIER);
|
||||||
COMPILE_EMSG(MissingParentheses, JSMSG_MISSING_PAREN);
|
COMPILE_EMSG(MissingParentheses, JSMSG_MISSING_PAREN);
|
||||||
COMPILE_EMSG(ParenthesesUnmatched, JSMSG_UNMATCHED_RIGHT_PAREN);
|
COMPILE_EMSG(ParenthesesUnmatched, JSMSG_UNMATCHED_RIGHT_PAREN);
|
||||||
COMPILE_EMSG(ParenthesesTypeInvalid, JSMSG_BAD_QUANTIFIER); /* "(?" with bad next char */
|
COMPILE_EMSG(ParenthesesTypeInvalid, JSMSG_BAD_QUANTIFIER);
|
||||||
COMPILE_EMSG(CharacterClassUnmatched, JSMSG_BAD_CLASS_RANGE);
|
COMPILE_EMSG(CharacterClassUnmatched, JSMSG_BAD_CLASS_RANGE);
|
||||||
COMPILE_EMSG(CharacterClassOutOfOrder, JSMSG_BAD_CLASS_RANGE);
|
COMPILE_EMSG(CharacterClassOutOfOrder, JSMSG_BAD_CLASS_RANGE);
|
||||||
COMPILE_EMSG(CharacterClassRangeSingleChar, JSMSG_BAD_CLASS_RANGE);
|
|
||||||
COMPILE_EMSG(EscapeUnterminated, JSMSG_TRAILING_SLASH);
|
COMPILE_EMSG(EscapeUnterminated, JSMSG_TRAILING_SLASH);
|
||||||
COMPILE_EMSG(QuantifierTooLarge, JSMSG_BAD_QUANTIFIER);
|
COMPILE_EMSG(QuantifierTooLarge, JSMSG_BAD_QUANTIFIER);
|
||||||
#undef COMPILE_EMSG
|
#undef COMPILE_EMSG
|
||||||
|
@ -53,6 +53,7 @@ script regress-375642.js
|
|||||||
script regress-375651.js
|
script regress-375651.js
|
||||||
script regress-375711.js
|
script regress-375711.js
|
||||||
script regress-375715-01-n.js
|
script regress-375715-01-n.js
|
||||||
|
script regress-375715-02.js
|
||||||
script regress-375715-03.js
|
script regress-375715-03.js
|
||||||
script regress-375715-04.js
|
script regress-375715-04.js
|
||||||
script regress-436700.js
|
script regress-436700.js
|
||||||
|
59
js/src/tests/ecma_3/RegExp/regress-375715-02.js
Normal file
59
js/src/tests/ecma_3/RegExp/regress-375715-02.js
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is JavaScript Engine testing utilities.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Mozilla Foundation.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s): Jesse Ruderman
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
var BUGNUMBER = 375715;
|
||||||
|
var summary = 'Do not assert: (c2 <= cs->length) && (c1 <= c2)';
|
||||||
|
var actual = '';
|
||||||
|
var expect = '';
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
test();
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function test()
|
||||||
|
{
|
||||||
|
enterFunc ('test');
|
||||||
|
printBugNumber(BUGNUMBER);
|
||||||
|
printStatus (summary);
|
||||||
|
|
||||||
|
/[\s-:]/;
|
||||||
|
reportCompare(expect, actual, summary + '/[\s-:]/');
|
||||||
|
|
||||||
|
exitFunc ('test');
|
||||||
|
}
|
@ -39,22 +39,6 @@ enum BuiltInCharacterClassID {
|
|||||||
NewlineClassID
|
NewlineClassID
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ErrorCode {
|
|
||||||
NoError,
|
|
||||||
PatternTooLarge,
|
|
||||||
QuantifierOutOfOrder,
|
|
||||||
QuantifierWithoutAtom,
|
|
||||||
MissingParentheses,
|
|
||||||
ParenthesesUnmatched,
|
|
||||||
ParenthesesTypeInvalid,
|
|
||||||
CharacterClassUnmatched,
|
|
||||||
CharacterClassOutOfOrder,
|
|
||||||
CharacterClassRangeSingleChar,
|
|
||||||
EscapeUnterminated,
|
|
||||||
QuantifierTooLarge,
|
|
||||||
NumberOfErrorCodes
|
|
||||||
};
|
|
||||||
|
|
||||||
// The Parser class should not be used directly - only via the Yarr::parse() method.
|
// The Parser class should not be used directly - only via the Yarr::parse() method.
|
||||||
template<class Delegate>
|
template<class Delegate>
|
||||||
class Parser {
|
class Parser {
|
||||||
@ -62,6 +46,21 @@ private:
|
|||||||
template<class FriendDelegate>
|
template<class FriendDelegate>
|
||||||
friend int parse(FriendDelegate& delegate, const UString& pattern, unsigned backReferenceLimit);
|
friend int parse(FriendDelegate& delegate, const UString& pattern, unsigned backReferenceLimit);
|
||||||
|
|
||||||
|
enum ErrorCode {
|
||||||
|
NoError,
|
||||||
|
PatternTooLarge,
|
||||||
|
QuantifierOutOfOrder,
|
||||||
|
QuantifierWithoutAtom,
|
||||||
|
MissingParentheses,
|
||||||
|
ParenthesesUnmatched,
|
||||||
|
ParenthesesTypeInvalid,
|
||||||
|
CharacterClassUnmatched,
|
||||||
|
CharacterClassOutOfOrder,
|
||||||
|
EscapeUnterminated,
|
||||||
|
QuantifierTooLarge,
|
||||||
|
NumberOfErrorCodes
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CharacterClassParserDelegate:
|
* CharacterClassParserDelegate:
|
||||||
*
|
*
|
||||||
@ -77,7 +76,6 @@ private:
|
|||||||
: m_delegate(delegate)
|
: m_delegate(delegate)
|
||||||
, m_err(err)
|
, m_err(err)
|
||||||
, m_state(empty)
|
, m_state(empty)
|
||||||
, m_sawCharacterClass(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,14 +107,6 @@ private:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case cachedCharacter:
|
case cachedCharacter:
|
||||||
// This guard handles things like /[\s-d]/.
|
|
||||||
if ((m_character == '-') && m_sawCharacterClass) {
|
|
||||||
m_err = CharacterClassRangeSingleChar;
|
|
||||||
m_state = empty;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sawCharacterClass = false;
|
|
||||||
if (ch == '-')
|
if (ch == '-')
|
||||||
m_state = cachedCharacterHyphen;
|
m_state = cachedCharacterHyphen;
|
||||||
else {
|
else {
|
||||||
@ -148,7 +138,6 @@ private:
|
|||||||
flush();
|
flush();
|
||||||
|
|
||||||
atomPatternCharacterUnescaped(ch);
|
atomPatternCharacterUnescaped(ch);
|
||||||
m_sawCharacterClass = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -158,20 +147,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
void atomBuiltInCharacterClass(BuiltInCharacterClassID classID, bool invert)
|
void atomBuiltInCharacterClass(BuiltInCharacterClassID classID, bool invert)
|
||||||
{
|
{
|
||||||
// The first part of this guard handles things like /[a-\d]/ and the
|
|
||||||
// second part handles things like /[\w-\s]/.
|
|
||||||
if (m_state == cachedCharacterHyphen ||
|
|
||||||
(m_sawCharacterClass && (m_state == cachedCharacter) && m_character == '-')) {
|
|
||||||
// If the RHS of a range does not contain exacly one character then a SyntaxError
|
|
||||||
// must be thrown.
|
|
||||||
// Assumes none of the built in character classes contain a single character.
|
|
||||||
m_err = CharacterClassRangeSingleChar;
|
|
||||||
m_state = empty;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
flush();
|
flush();
|
||||||
m_delegate.atomCharacterClassBuiltIn(classID, invert);
|
m_delegate.atomCharacterClassBuiltIn(classID, invert);
|
||||||
m_sawCharacterClass = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -207,8 +184,6 @@ private:
|
|||||||
cachedCharacter,
|
cachedCharacter,
|
||||||
cachedCharacterHyphen
|
cachedCharacterHyphen
|
||||||
} m_state;
|
} m_state;
|
||||||
// Used to verify that there is not a character class on the LHS of a range.
|
|
||||||
bool m_sawCharacterClass;
|
|
||||||
UChar m_character;
|
UChar m_character;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -429,7 +404,7 @@ private:
|
|||||||
/*
|
/*
|
||||||
* parseCharacterClass():
|
* parseCharacterClass():
|
||||||
*
|
*
|
||||||
* Helper for parseTokens(); calls directly and indirectly (via parseCharacterClassEscape)
|
* Helper for parseTokens(); calls dirctly and indirectly (via parseCharacterClassEscape)
|
||||||
* to an instance of CharacterClassParserDelegate, to describe the character class to the
|
* to an instance of CharacterClassParserDelegate, to describe the character class to the
|
||||||
* delegate.
|
* delegate.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user