ID: 39536
User updated by: vpavlov at rila dot bg
Reported By: vpavlov at rila dot bg
Status: Bogus
Bug Type: Filesystem function related
Operating System: Linux (SLES 9)
PHP Version: 4.4.4
New Comment:
Well, if that's your notion of well written documentation... At the
very least it's misleading. Changing the text to read "...including
text and binary files..." will sure save a lot of hassle to people with
the same problem.
Previous Comments:
------------------------------------------------------------------------
[2006-11-16 16:56:04] [EMAIL PROTECTED]
That's right, this is how magic_quotes_runtime are supposed to work.
And there is nothing wrong with the docs. Yes, "*from
any sort of external source* *including* databases and text files".
"Including" doesn't mean "only".
------------------------------------------------------------------------
[2006-11-16 16:30:26] vpavlov at rila dot bg
Description:
------------
using fread() on a file opened with fopen(..., "rb") will mis-read the
file when magic_quotes_runtime is ON. According to documentation:
If magic_quotes_runtime is enabled, most functions that return data
from any sort of external source including databases and ->text files<-
will have quotes escaped with a backslash.
Reproduce code:
---------------
// TEST 1
set_magic_quotes_runtime(1);
$fp = fopen("bahor.zip", "rb");
$contents = fread($fp, filesize("bahor.zip"));
echo strlen($contents) . "\n";
echo filesize("bahor.zip") . "\n";
fclose($fp);
// TEST 2
set_magic_quotes_runtime(0);
$fp = fopen("bahor.zip", "rb");
$contents = fread($fp, filesize("bahor.zip"));
echo strlen($contents) . "\n";
echo filesize("bahor.zip") . "\n";
fclose($fp);
Expected result:
----------------
When I say binary I do mean binary, regardless of what some option
claims. In the code above, the two sections should produce the same
results, the exact size of the zip file.
Actual result:
--------------
In test 1 the sizes reported by filesize("bahor.zip") and
strlen($contents) are different, due to the escaping which occurs
because of magic_quotes_runtime being On
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39536&edit=1