Bug #75355 [Opn->Csd]: preg_quote() does not quote # control character

From: Date: Sat, 16 Dec 2017 16:35:09 +0000
Subject: Bug #75355 [Opn->Csd]: preg_quote() does not quote # control character
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213131@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75355&edit=1 ID: 75355 Updated by: nikic@php.net Reported by: bugs dot php dot net at majkl578 dot cz Summary: preg_quote() does not quote # control character -Status: Open +Status: Closed Type: Bug Package: PCRE related Operating System: - PHP Version: 7.2.0RC3 Block user comment: N Private report: N New Comment: Automatic comment on behalf of mail@majkl578.cz Revision: http://git.php.net/?p=php-src.git;a=commit;h=84235344f96e11b88ed5a2060baed5532718a46f Log: Fixed bug #75355: preg_quote() does not quote # control character Previous Comments: ------------------------------------------------------------------------ [2017-10-10 16:51:08] bugs dot php dot net at majkl578 dot cz Description: ------------ Since # character is used as a control character to start comments (in extended mode - the 'x' modifier), it should also be quoted by preg_quote(). Unquoted # character corrupts the pattern in extended mode even after preg_quote() has been applied. Test script: --------------- <?php preg_match('~^(' . preg_quote('hello#world', '~') . ')\z~x', 'hello#world') Expected result: ---------------- No error, # is properly escaped. Actual result: -------------- Warning: preg_match(): Compilation failed: missing ) at offset 16 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75355&edit=1

« previous php.bugs (#213131) next »