forked from Botanical/BotanJS
Guarding for infinite loop
This commit is contained in:
parent
fbb4bae316
commit
a72dcd8ca9
@ -39,7 +39,7 @@
|
||||
}
|
||||
|
||||
// The root bracket as back ref 0
|
||||
var RegEx = new RegExp( "(" + parsed + ")", "g" );
|
||||
var RegEx = new RegExp( "(" + parsed + ")", "gm" );
|
||||
|
||||
return RegEx;
|
||||
};
|
||||
@ -104,9 +104,20 @@
|
||||
var FirstHit;
|
||||
var PrevStack = [];
|
||||
|
||||
var LoopGuard;
|
||||
while( ( r = search.exec( content ) ) !== null )
|
||||
{
|
||||
if( !FirstHit ) FirstHit = r.index;
|
||||
if( FirstHit == undefined )
|
||||
{
|
||||
FirstHit = r.index;
|
||||
}
|
||||
|
||||
if( LoopGuard == r.index )
|
||||
{
|
||||
this.__msg = VimError( "EX2", PATTERN.slice( 1 ).join( "" ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
if( p < r.index )
|
||||
{
|
||||
Hit = r.index;
|
||||
@ -114,6 +125,7 @@
|
||||
}
|
||||
|
||||
PrevStack.push( r.index );
|
||||
LoopGuard = r.index;
|
||||
}
|
||||
|
||||
if( e.kMap( "N" ) )
|
||||
|
@ -38,6 +38,7 @@ VIMRE_VERSION = "1.0.0b";
|
||||
|
||||
// EXtended Errors
|
||||
, "EX1": "Pattern Error( %1 )"
|
||||
, "EX2": "This pattern is causing infinite loop: %1"
|
||||
|
||||
, "TODO": "%1 is not implemented yet"
|
||||
, "MISSING_FEATURE": "Sorry, I thought this command wasn't useful enough to implement. Please file a feature request titled \"Implement %1\" in github if you think this is important."
|
||||
|
Loading…
Reference in New Issue
Block a user