Bug #75355 [NEW]: preg_quote() does not quote # control character

From: Date: Tue, 10 Oct 2017 16:51:13 +0000
Subject: Bug #75355 [NEW]: preg_quote() does not quote # control character
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211615@lists.php.net to get a copy of this message
From: bugs dot php dot net at majkl578 dot cz Operating system: - PHP version: 7.2.0RC3 Package: PCRE related Bug Type: Bug Bug description:preg_quote() does not quote # control character 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 bug report at https://bugs.php.net/bug.php?id=75355&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75355&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75355&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75355&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75355&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75355&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75355&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75355&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75355&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75355&r=support Expected behavior: https://bugs.php.net/fix.php?id=75355&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75355&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75355&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75355&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75355&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75355&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75355&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75355&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75355&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75355&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75355&r=mysqlcfg

« previous php.bugs (#211615) next »