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

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

 New Comment:

Abc, please double-read my issue ;) 

So once more:

1) preg_quote is quoting characters (these =  !  <  > : ) which may not be 
quoted. Could you show me scenario, when these (again, THESE) characters should 
be escaped?

2) in documentation is missing information that preg_quote quotes \x00


Previous Comments:
------------------------------------------------------------------------
[2013-07-18 05:33:25] a...@php.net

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);

------------------------------------------------------------------------
[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