Ignore:
Timestamp:
Nov 16, 2010, 3:27:13 PM (15 years ago)
Author:
[email protected]
Message:

2010-11-16 Peter Varga <[email protected]>

Reviewed by Gavin Barraclough.

The number of recursive match calls isn't limited in YARR Interpreter
https://bugs.webkit.org/show_bug.cgi?id=47906

Check the number of the matchDisjunction recursive calls to avoid unbounded
recursion.
Now the matchDisjunction function returns JSRegExpResult instead of bool.
The JSRegExpResult enum contains the result of matching or the error code
of the failure (like HitLimit) which terminates the matching.
The error codes are based on pcre's jsRegExpExecute error codes.

  • yarr/RegexInterpreter.cpp: (JSC::Yarr::Interpreter::parenthesesDoBacktrack): (JSC::Yarr::Interpreter::matchParentheses): (JSC::Yarr::Interpreter::backtrackParentheses): (JSC::Yarr::Interpreter::matchDisjunction): (JSC::Yarr::Interpreter::matchNonZeroDisjunction): (JSC::Yarr::Interpreter::interpret): (JSC::Yarr::Interpreter::Interpreter):
  • yarr/RegexInterpreter.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/yarr/RegexInterpreter.h

    r68127 r72140  
    4040
    4141namespace JSC { namespace Yarr {
     42
     43// TODO move the matchLimit constant and the JSRegExpResult enum to the JSRegExp.h when pcre is removed.
     44
     45// The below limit restricts the number of "recursive" match calls in order to
     46// avoid spending exponential time on complex regular expressions.
     47static const unsigned matchLimit = 1000000;
     48
     49enum JSRegExpResult {
     50    JSRegExpMatch = 1,
     51    JSRegExpNoMatch = 0,
     52    JSRegExpErrorNoMatch = -1,
     53    JSRegExpErrorHitLimit = -2,
     54    JSRegExpErrorNoMemory = -3,
     55    JSRegExpErrorInternal = -4
     56};
    4257
    4358class ByteDisjunction;
Note: See TracChangeset for help on using the changeset viewer.