From 84235344f96e11b88ed5a2060baed5532718a46f Mon Sep 17 00:00:00 2001 From: Michael Moravec Date: Tue, 10 Oct 2017 19:00:29 +0200 Subject: [PATCH] Fixed bug #75355: preg_quote() does not quote # control character --- NEWS | 6 ++++++ ext/pcre/php_pcre.c | 2 ++ ext/pcre/tests/bug75355.phpt | 15 +++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 ext/pcre/tests/bug75355.phpt diff --git a/NEWS b/NEWS index 2441f288ae..b495f74782 100644 --- 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) diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 3b6f795a8c..47f22a57f8 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -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 index 0000000000..d37d781bc1 --- /dev/null +++ b/ext/pcre/tests/bug75355.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #75355 (preg_quote() does not quote # control character) +--FILE-- + +--EXPECT-- +string(2) "\#" +int(1) +string(11) "hello#world" -- 2.50.1