|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75355 preg_quote() does not quote # control character
Submitted: 2017-10-10 16:51 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: bugs dot php dot net at majkl578 dot cz Assigned:
Status: Closed Package: PCRE related
PHP Version: 7.2.0RC3 OS: -
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: bugs dot php dot net at majkl578 dot cz
New email:
PHP Version: OS:


 [2017-10-10 16:51 UTC] bugs dot php dot net at majkl578 dot cz
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:

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


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-16 16:35 UTC]
Automatic comment on behalf of
Log: Fixed bug #75355: preg_quote() does not quote # control character
 [2017-12-16 16:35 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Jun 01 09:03:38 2023 UTC