]> granicus.if.org Git - php/commitdiff
Fixed bug #75355: preg_quote() does not quote # control character
authorMichael Moravec <mail@majkl578.cz>
Tue, 10 Oct 2017 17:00:29 +0000 (19:00 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 16 Dec 2017 16:34:41 +0000 (17:34 +0100)
NEWS
ext/pcre/php_pcre.c
ext/pcre/tests/bug75355.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 2441f288ae15d18548d0b9850d5e76cc3fda5743..b495f747821ecbaa4f20bbdec25aca3ad4bf2cec 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -93,6 +93,8 @@ PHP                                                                        NEWS
 
 - PCRE:
   . Implemented https://wiki.php.net/rfc/pcre2-migration (Anatol, Dmitry)
+  . Fixed bug #75355 (preg_quote() does not quote # control character).
+    (Michael Moravec)
 
 - PDO_DBlib:
   . Implemented request #69592 (allow 0-column rowsets to be skipped
@@ -109,6 +111,10 @@ PHP                                                                        NEWS
 - PDO SQLite
   . Add support for additional open flags
 
+- PCRE:
+  . Fixed bug #75355 (preg_quote() does not quote # control character).
+    (Majkl578)
+
 - phar:
   . Fixed bug #74991 (include_path has a 4096 char limit in some cases).
     (bwbroersma)
index 3b6f795a8c601f9d8b3ae4eddb32a54a7747cc46..47f22a57f8dec1a9b37e0d51928d9069803faed2 100644 (file)
@@ -2629,6 +2629,7 @@ static PHP_FUNCTION(preg_quote)
                        case '|':
                        case ':':
                        case '-':
+                       case '#':
                                extra_len++;
                                break;
 
@@ -2678,6 +2679,7 @@ static PHP_FUNCTION(preg_quote)
                        case '|':
                        case ':':
                        case '-':
+                       case '#':
                                *q++ = '\\';
                                *q++ = c;
                                break;
diff --git a/ext/pcre/tests/bug75355.phpt b/ext/pcre/tests/bug75355.phpt
new file mode 100644 (file)
index 0000000..d37d781
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #75355 (preg_quote() does not quote # control character)
+--FILE--
+<?php
+
+var_dump(preg_quote('#'));
+
+var_dump(preg_match('~^(' . preg_quote('hello#world', '~') . ')\z~x', 'hello#world', $m));
+
+var_dump($m[1]);
+?>
+--EXPECT--
+string(2) "\#"
+int(1)
+string(11) "hello#world"