Bug #64912 [Opn->Fbk]: Unexpected output when parsing PHP files containing NUL characters

From: Date: Sat, 29 Jun 2013 05:25:34 +0000
Subject: Bug #64912 [Opn->Fbk]: Unexpected output when parsing PHP files containing NUL characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-179966@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64912&edit=1 ID: 64912 Updated by: yohgaki@php.net Reported by: alexander dot stehlik at gmail dot com Summary: Unexpected output when parsing PHP files containing NUL characters -Status: Open +Status: Feedback Type: Bug Package: mbstring related Operating System: Linux (Ubuntu and CentOS) PHP Version: 5.4.15 Block user comment: N Private report: N New Comment: With 5.4.16, I get $ php -n -d mbstring.internal_encoding=utf-8 test.php testTEST $ php -n -d zend.multibyte=on -d mbstring.internal_encoding=utf-8 test.php Fatal error: Could not convert the script from the detected encoding "UTF-16BE" to a compatible encoding in Unknown on line 0 test.php <?php echo "test^@TEST";?> where ^@ is actual null char. e.g. $ echo -e "<?php echo \"test\0TEST\";?>" > test.php With some Japanese, I got the same result. $ php -n -d mbstring.internal_encoding=utf-8 test.php 日本語あいうえおtestTEST $ php -n -d zend.multibyte=on -d mbstring.internal_encoding=utf-8 test.php Fatal error: Could not convert the script from the detected encoding "UTF-16BE" to a compatible encoding in Unknown on line 0 Are you using the exact same test script or using more complex script? Previous Comments: ------------------------------------------------------------------------ [2013-05-23 17:31:10] alexander dot stehlik at gmail dot com Description: ------------ When this setting is used: zend.multibyte = On and I parse a PHP file that contains a NUL character (this one here: http://en.wikipedia.org/wiki/Null_character) I get some weird output. When I do not use the mbstring.internal_encoding setting I get a lot of question marks (?). When I use mbstring.internal_encoding = utf-8 I get some characters that look like Chinese to me. Test script: --------------- <?php // I can not insert the NUL character here. // To put it in a PHP file you can use the console: // // echo -e "here is \0 null" >> test.php $var = 'here is <InsertNULCharacterHere> null'; ?> Expected result: ---------------- When I run the given example with php test.php I expect no output, even when this setting is active: zend.multibyte = On Actual result: -------------- With the setting zend.multibyte = On I get some weird output (depending on the configured internal encoding): With the setting mbstring.internal_encoding = utf-8 I get an output that looks like this: 㰿灨瀊⑶慲‽‧桥物⁳椠 湵汬✻ਿ㸊 Without the setting the output looks like this: ??????????? ????? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64912&edit=1

« previous php.bugs (#179966) next »