From 67e450115aa85c86fcfeaa356143f3d5d2487d66 Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Thu, 28 Jul 2016 12:38:26 +1000 Subject: [PATCH] parser: ignore \E that is not preceded by \Q This conforms to PCRE's behaviour, where an isolated \E that is not preceded by \Q is ignored. --- src/parser/Parser.rl | 5 ++--- unit/hyperscan/bad_patterns.txt | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/parser/Parser.rl b/src/parser/Parser.rl index 9bd4d96d..53130ddf 100644 --- a/src/parser/Parser.rl +++ b/src/parser/Parser.rl @@ -1226,9 +1226,8 @@ unichar readUtf8CodePoint4c(const u8 *ts) { '\\Q' => { fgoto readQuotedLiteral; }; - '\\E' => { - throw LocatedParseError("Unmatched \\E"); - }; + # An \E that is not preceded by a \Q is ignored + '\\E' => { /* noop */ }; # Match any character '\.' => { currentSeq->addComponent(generateComponent(CLASS_ANY, false, mode)); diff --git a/unit/hyperscan/bad_patterns.txt b/unit/hyperscan/bad_patterns.txt index 9fc3a413..1a33210d 100644 --- a/unit/hyperscan/bad_patterns.txt +++ b/unit/hyperscan/bad_patterns.txt @@ -32,7 +32,6 @@ 31:/\B/W #\B unsupported in UCP mode at index 0. 32:/foo(?{print "Hello world\n";})bar/ #Embedded code is not supported at index 3. 33:/the (\S+)(?{ $color = $^N }) (\S+)(?{ $animal = $^N })/i #Embedded code is not supported at index 9. -34:/foobar\E/s #Unmatched \E at index 6. 35:/\X/8 #\X unsupported at index 0. 36:/\B+/ #Invalid repeat at index 2. 37:/\B?/ #Invalid repeat at index 2.