php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48589 /\Q$z\E/ matches every string
Submitted: 2009-06-17 20:23 UTC Modified: 2009-06-17 23:04 UTC
From: mjs at beebo dot org Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.9 OS: OS X
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mjs at beebo dot org
New email:
PHP Version: OS:

 

 [2009-06-17 20:23 UTC] mjs at beebo dot org
Description:
------------
The regular expression /\Q$z\E/ matches (as far as I can tell) every 
string.  It certainly matches some strings it shouldn't match:

preg_match("/\Q$z\E/", "") -> MATCH (WRONG!)
preg_match("/\Q$z\E/", "qqqq") -> MATCH (WRONG!)

preg_match("/\Q $z\E/", "qqqq") -> NO MATCH (CORRECT)
preg_match("/\Q $z\E/", " $z") -> MATCH (CORRECT)
preg_match("/\Q\$z\E/", "\$z") -> MATCH (CORRECT)
preg_match("/\Q\$z\E/", "$z") -> NO MATCH (CORRECT)

The problem seems to occur if the regular expression begins with the 
string "\Q$" followed by at least one character.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-17 20:45 UTC] mjs at beebo dot org
Regexp documentation:

http://php.net/manual/en/regexp.reference.php
 [2009-06-17 22:58 UTC] felipe@php.net
No bug there, the '$z' enclosed by double quotes is interpreted as a variable first.

http://docs.php.net/manual/en/language.types.string.php
 [2009-06-17 23:04 UTC] mjs at beebo dot org
Ah yes of course, apologies.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 11 00:01:31 2024 UTC