php.net |  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: -
Votes:1
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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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
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

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-12-16 16:35 UTC] nikic@php.net
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
 [2017-12-16 16:35 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 16 07:01:27 2024 UTC