#40395 [Opn->Bgs]: PCRE engine unable to output NULL characters
| From: | tony2001@php.net | Date: | Thu, 08 Feb 2007 00:26:15 +0000 |
| Subject: | #40395 [Opn->Bgs]: PCRE engine unable to output NULL characters | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-108566@lists.php.net to get a copy of this message | ||
ID: 40395
Updated by: tony2001@php.net
Reported By: jfrim at idirect dot com
-Status: Open
+Status: Bogus
Bug Type: PCRE related
Operating System: Win98SE
PHP Version: 5.2.0
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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