Edit report at https://bugs.php.net/bug.php?id=65283&edit=1

 ID:                 65283
 Updated by:         a...@php.net
 Reported by:        david at grudl dot com
 Summary:            preg_quote escapes unnecessary characters + Doc
-Status:             Open
+Status:             Not a bug
 Type:               Feature/Change Request
 Package:            PCRE related
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

from the doc 

"preg_quote — Quote regular expression characters"

so that's exactly what you blame ;)

the scenario is pretty simple

$pattern = '[/';
preg_match('/' . preg_quote($pattern) . '/', $subj);


Previous Comments:
------------------------------------------------------------------------
[2013-07-18 00:27:52] david at grudl dot com

Description:
------------
preg_quote() escapes all PCRE metacharacters. It also escapes these characters 
= ! < > : which have no special meaning. I am unable to find out any scenario 
when these characters should be escaped, do you? For assertions it is enough to 
escape ?. So they shouldn't be escaped.

There is also problem in documentation, preg_quote escapes \x00, but it is not 
mentioned.



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65283&edit=1

Reply via email to