]> granicus.if.org Git - php/commitdiff
Fix #77827: preg_match does not ignore \r in regex flags
authorChristoph M. Becker <cmbecker69@gmx.de>
Sun, 31 Mar 2019 11:31:54 +0000 (13:31 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Sun, 31 Mar 2019 11:31:54 +0000 (13:31 +0200)
NEWS
ext/pcre/php_pcre.c
ext/pcre/tests/bug77827.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 81d172797beb644b2506b342898f9a313c407800..67028cd64c896d42483715ccad7382fbf0d9d39c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,10 @@ PHP                                                                        NEWS
   . Fixed bug #72175 (Impossibility of creating multiple connections to
     Interbase with php 7.x). (Nikita)
 
+- PCRE:
+  . Fixed bug #77827 (preg_match does not ignore \r in regex flags). (requinix,
+    cmb)
+
 - phpdbg:
   . Fixed bug #76801 (too many open files). (alekitto)
   . Fixed bug #77800 (phpdbg segfaults on listing some conditional breakpoints).
index 4cdd8bf27c7c5313f352df46f949ce2d0cd31e82..2e827298a97e7416bb9d06cd8376f575917a8f27 100644 (file)
@@ -486,6 +486,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
 
                        case ' ':
                        case '\n':
+                       case '\r':
                                break;
 
                        default:
diff --git a/ext/pcre/tests/bug77827.phpt b/ext/pcre/tests/bug77827.phpt
new file mode 100644 (file)
index 0000000..c8f8c7a
--- /dev/null
@@ -0,0 +1,14 @@
+--TEST--
+Bug #77827 (preg_match does not ignore \r in regex flags)
+--FILE--
+<?php
+var_dump(
+    preg_match("/foo/i\r", 'FOO'),
+    preg_last_error()
+);
+?>
+===DONE===
+--EXPECT--
+int(1)
+int(0)
+===DONE===