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

 ID:                 60395
 Updated by:         larue...@php.net
 Reported by:        nh at ngin dot de
 Summary:            Null byte in source causes file to be ignored, no
                     error or warning reported
 Status:             Open
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   any
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

you must compile your php with zend-multibyte supporting. 

try this, php -ddetect_unicode = 0 test.php

I think this is not a bug,  but a side-effect of zend multibyte auto-unicode-
detection :)


Previous Comments:
------------------------------------------------------------------------
[2011-11-26 23:17:30] nh at ngin dot de

Description:
------------
NULL bytes in the source code seem to confuse PHP. See test script below. The 
code in the file is not executed, and no error or warning is shown.

The result is the same if you run it from the command line or from a web server 
(ruling out a web server problem).

This bug has been discovered on MacOS X (10.6.8) with a default, unpatched PHP 
5.3.6; but it has been reproduced (so far) as well on Debian 2.6.26-2 with the 
most recent version of PHP.

It does not matter where the null byte(s) is/are placed. They can even be 
inside 
a comment!

I discovered this bug by accident as I had inadvertently copied a NULL-byte 
into 
a comment inside a file that I was require()'ing from elsewhere. The 
require()'d 
code was not run, but, even with error_reporting(-1), no warning or error 
message was displayed. I couldn't figure out what was wrong until I looked at 
the file with a text editor that can make non-printing characters visible. 
Removing the NULL byte fixed the problem.

Test script:
---------------
This is a 1-line PHP script that contains a single NULL byte:
http://dl.dropbox.com/u/257587/test.php

Just showing printable chars, the contents of this file is:
<?php echo "Hi"; ?>

The NULL byte is located after the closing semicolon. (However, the exact 
location is irrelevant in order to reproduce the bug.)

Expected result:
----------------
The string 'Hi' should be output.

Actual result:
--------------
Instead, PHP outputs a number of non-printing characters (usually shown as 
question marks). Depending on the position and number of NULL bytes in the 
source 
code, the output may also be nothing at all.


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



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

Reply via email to