ID: 40395 User updated by: jfrim at idirect dot com Reported By: jfrim at idirect dot com Status: Bogus Bug Type: PCRE related Operating System: Win98SE PHP Version: 5.2.0 New Comment:
I'd also like to present bug #16590: http://bugs.php.net/bug.php?id=16590 Note the following example they list as a SOLUTION to specifying NULLs in the pattern: preg_match("/\\x00/", "foo\0bar") And note the following statement from bug report #16590: "...The docs state that PCRE is binary safe..." So if PCRE is binary safe, and you can specify NULLs in the pattern with \x00, why are back references unable to return these matched NULLs?!?!? How is this NOT a bug?!?? Previous Comments: ------------------------------------------------------------------------ [2007-02-08 05:32:20] jfrim at idirect dot com If the regular expression were /([\x00-\xFF])/ , you would think EVERY possible byte value would be matched. In fact, all of them do get matched. However, all of them EXCEPT for byte value 0x00 is returned in the \1 back reference. Any 0x00 bytes are returned as two bytes, 0x5C followed by 0x30. I have not found in any Perl regular expression documentation an explanation for why the 0x00 byte is handled like this, so could you please tell me why this is NOT a bug with PCRE. Thanks. ------------------------------------------------------------------------ [2007-02-08 00:26:14] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. ------------------------------------------------------------------------ [2007-02-08 00:04:01] jfrim at idirect dot com Description: ------------ The PERL-compatible regular expression engine is unable to output NULL characters correctly. This is evident with the preg_replace() function (tested), and seems likely evident with other PCRE functions (untested) according to some other but reports already submitted. Instead of returning a NULL character, a literal '\0' sequence is returned. Reproduce code: --------------- <?php $inputstring = "ASCII NUL\0, SOH\01, STX\02, ETX\03"; echo preg_replace('/([\\x00-\\x02])/e',"'['.ord('\\1').']'",$inputstring); ?> Expected result: ---------------- ASCII NUL[0], SOH[1], STX[2], ETX (Note that "ETX" is immediately followed by ctrl char #3) Actual result: -------------- ASCII NUL[92], SOH[1], STX[2], ETX (Note that "ETX" is immediately followed by ctrl char #3) The "92" is present in place of what should be "0" because preg_replace() incorrectly returns a literal '\0' sequence instead of a NULL character, and the ord() function then returns the value of the literal backslash. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40395&edit=1