Fixed bug #75355: preg_quote() does not quote # control character

This commit is contained in:
Michael Moravec 2017-10-10 19:00:29 +02:00 committed by Nikita Popov
parent abdece72c2
commit 84235344f9
3 changed files with 23 additions and 0 deletions

6
NEWS
View file

@ -93,6 +93,8 @@ PHP NEWS
- PCRE: - PCRE:
. Implemented https://wiki.php.net/rfc/pcre2-migration (Anatol, Dmitry) . Implemented https://wiki.php.net/rfc/pcre2-migration (Anatol, Dmitry)
. Fixed bug #75355 (preg_quote() does not quote # control character).
(Michael Moravec)
- PDO_DBlib: - PDO_DBlib:
. Implemented request #69592 (allow 0-column rowsets to be skipped . Implemented request #69592 (allow 0-column rowsets to be skipped
@ -109,6 +111,10 @@ PHP NEWS
- PDO SQLite - PDO SQLite
. Add support for additional open flags . Add support for additional open flags
- PCRE:
. Fixed bug #75355 (preg_quote() does not quote # control character).
(Majkl578)
- phar: - phar:
. Fixed bug #74991 (include_path has a 4096 char limit in some cases). . Fixed bug #74991 (include_path has a 4096 char limit in some cases).
(bwbroersma) (bwbroersma)

View file

@ -2629,6 +2629,7 @@ static PHP_FUNCTION(preg_quote)
case '|': case '|':
case ':': case ':':
case '-': case '-':
case '#':
extra_len++; extra_len++;
break; break;
@ -2678,6 +2679,7 @@ static PHP_FUNCTION(preg_quote)
case '|': case '|':
case ':': case ':':
case '-': case '-':
case '#':
*q++ = '\\'; *q++ = '\\';
*q++ = c; *q++ = c;
break; break;

View file

@ -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"