]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
parser: ignore \E that is not preceded by \Q
authorJustin Viiret <justin.viiret@intel.com>
Thu, 28 Jul 2016 02:38:26 +0000 (12:38 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 10 Aug 2016 05:08:01 +0000 (15:08 +1000)
This conforms to PCRE's behaviour, where an isolated \E that is not
preceded by \Q is ignored.

src/parser/Parser.rl
unit/hyperscan/bad_patterns.txt

index 9bd4d96d5ce20f5dfe35691b716e9dedc37fbd03..53130ddf322ce9e4585f76ef83461290bb4f241f 100644 (file)
@@ -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));
index 9fc3a41339ea414424fb60cbafaf1ef023879f59..1a33210d11d8efc2826b6b5fdfdc778a546f9529 100644 (file)
@@ -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.