ID: 44072
Comment by: yar_helg at mail dot ru
Reported By: sergey89 at gmail dot com
Status: No Feedback
Bug Type: Strings related
Operating System: FreeBSD 6.3
PHP Version: 5.2.5
New Comment:
I have something like that on PHP 5.2.6 on Linux.
Here is a test script file:
===========================
<?php
echo "OS is ".PHP_OS."<br />\n";
echo "PHP is ".phpversion()."<br />\n";
echo "function overload = ".ini_get('mbstring.func_overload')."<br
/>\n";
//mb_internal_encoding('UTF-8');
echo "MB_INTERNAL_ENCODING =".mb_internal_encoding()."<br />\n";
define('IDENTIFIER_OLE',
pack("CCCCCCCC",0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1));
$data = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/substr_bug/empty
file.xls');
echo "Data length = ".strlen($data)."<br />\n";
echo "First 8 symbols ==>".var_export(substr($data,0,8),1)."<== <br
/>\n";
echo "Compare result (substr(\$data,0,8)==IDENTIFIER_OLE) -
".var_export(substr($data,0,8)==IDENTIFIER_OLE,1)."<br />\n";
echo "Substring length (substr(\$data,0,8)) -
".strlen(substr($data,0,8))."<br />\n";
?>
Output:
=======
OS is Linux
PHP is 5.2.6
function overload = 0
MB_INTERNAL_ENCODING =ISO-8859-1
Data length = 13824
First 8 symbols ==>'поЮ║╠А'<==
Compare result (substr($data,0,8)==IDENTIFIER_OLE) - true
Substring length (substr($data,0,8)) - 8
But if you uncomment line with
mb_internal_encoding('UTF-8');
output will be changed like that (look at the file size, result of
substr and length of substr result)...
Output with mb_internal_encoding=UTF-8:
=======================================
OS is Linux
PHP is 5.2.6
function overload = 0
MB_INTERNAL_ENCODING =UTF-8
Data length = 13824
First 8 symbols ==>'поЮ║╠А' .
"\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . ''<==
Compare result (substr($data,0,8)==IDENTIFIER_OLE) - false
Substring length (substr($data,0,8)) - 13
mbstring.func_overload is set to 0 in .htaccess file in current dir.
"empty file.xls" is an empty MS Excel 2003 file. Can be downloaded from
http://an-best.ru/empty_file.xls
Previous Comments:
------------------------------------------------------------------------
[2008-03-03 01:00:00] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2008-02-24 20:04:40] [EMAIL PROTECTED]
Can you just provide the script and data in e.g. zip package somewhere
where anyone can download it from? (those urls above are not working)
And shell access is not necessary for simple thing like
this..especially when I'm 99% sure you're just doing something wrong..
:)
------------------------------------------------------------------------
[2008-02-19 15:21:43] sergey89 at gmail dot com
> How do you know that the md5 sum for that part should be exactly
that?
I ran script on other PHP version and other OSes
PHP Script source: http://test.sergey89.net/test.php.txt
File containing data: http://test.sergey89.net/data
Result: http://test.sergey89.net/test.php
We can give you ftp/ssh access to test yourself.
------------------------------------------------------------------------
[2008-02-18 10:51:32] [EMAIL PROTECTED]
How do you know that the md5 sum for that part should be exactly that?
And we can't really test this reliably with some random data..
------------------------------------------------------------------------
[2008-02-15 15:13:33] sergey89 at gmail dot com
The version and build are the same.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/44072
--
Edit this bug report at http://bugs.php.net/?id=44072&edit=1