#23056 [Opn->Bgs]: gif and jpeg php generated pictures bug

From: Date: Mon, 07 Apr 2003 19:32:59 +0000
Subject: #23056 [Opn->Bgs]: gif and jpeg php generated pictures bug
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-37290@lists.php.net to get a copy of this message
ID: 23056 Updated by: rasmus@php.net Reported By: dan1 at edenpics dot com -Status: Open +Status: Bogus Bug Type: Output Control Operating System: Linux RedHat 7.1 PHP Version: 4.3.2RC1 New Comment: That c00\r\n is the HTTP chunk size which IE damn well better understand. And it is supposed to be there. That's not a bug at all. Read up on HTTP chunking please. Previous Comments: ------------------------------------------------------------------------ [2003-04-07 13:56:10] dan1 at edenpics dot com Dear Sniper and Rasmus. I understand your position. As I stated it in my report, everybody THINKS that it's an IE bug, but in fact it isn't. And I'm gonna proove it: I sniffed the output of bird.php, after a request made with Netscape 7.0. The same bug appears: there is a string like "c00\r\n" before the datas: "GIF89a2...". However, Netscape is more clever than IE and they knew about that bug, so they look for this string and forget it when it comes, so that we can correctly save the gif file. If it doesn't come with Netscape 4.7x, it's because they use the HTTP/1.0 protocol, and the bug comes only when you use an HTTP/1.1 request. In fact I tried the request with a web client I made myself. When I sniff the output of bird.php, the same appears: "c00\r\n". This was with windows XP. So I tried with a windows 98 station. The same happens: with IE or my self made program, the "c00\r\n" string comes out. This confirms that it's not an IE bug. However, perhaps it's an Apache bug, or even something else. I try to find it out, but what I'm sure of, it's that it's not IE, but really PHP/Apache. The only thing that disturbes me a bit, Rasmus, it's that you looked at the output too, but hadn't this strange string before the datas. Nevertheless, you made an HTTP/1.1 request, and this is the first time I see this, so I don't understand. Could you tell me what program you used to sniff the output ? And what OS do you have ? I personnally used Ethereal to sniff the datas. Perhaps it's a malformed TCP packet that shows the wrong start of the datas. Please try it with Ethereal, and you'll see it! Any clue ? ------------------------------------------------------------------------ [2003-04-06 06:38:15] sniper@php.net Here's much simpler script that can be used to reproduce this bug in IE6: <?php header("Content-type: image/gif"); header("Cache-Control: no-cache, must-revalidate"); readfile("bird.gif"); ?> And it really is bug in IE6..not in PHP. And it has actually existed in IE since IE5 too. Try search with google and you'll find couple of hundred hits about this. You might wanna try find out what cache preventing headers work for IE..it seems to be very picky about them. ------------------------------------------------------------------------ [2003-04-05 16:16:31] rasmus@php.net I don't see how this could possible be a PHP problem. I see nothing wrong with the output of your script. I sent an IE6 request and looked at the output. The headers sent by http://www.edenpics.com/pub/iebug/bird.php were: HTTP/1.1 200 OK Date: Sat, 05 Apr 2003 23:13:47 GMT Server: Apache X-Powered-By: PHP/4.1.2 Cache-Control: no-cache, must-revalidate Connection: close Content-Type: image/gif Followed by this gif datastream: 0000000 G I F 8 9 a 2 \0 ( \0 367 204 \0 001 002 002 0000020 003 002 \t 005 \n 017 \b 003 \b \f \n 002 \n \n \v 003 0000040 006 025 006 \t 035 \n \f 032 \f 021 036 024 024 026 020 024 0000060 036 \v 021 ! 016 023 ( 024 025 - 027 033 ) 022 031 2 0000100 033 036 0 032 $ . 025 # 8 033 ! < 030 ( : ! 0000120 + E # , N * 3 L ' 1 Q ' 1 \ 1 < 0000140 V / < b , > l + < r 7 E n : E g 0000160 < M m ; J s = L ~ ? P | A N x B I see nothing wrong. ------------------------------------------------------------------------ [2003-04-05 15:59:06] dan1 at edenpics dot com Yes, the bird was in JPEG before, I changed it in GIF, to be more coherent with the code. It's because I tested several formats, sorry for this incovenience. However, the bug appears in GIF or JPEG, so the bug is the same now. I just found out that the bug comes out only if we sent the "Cache-Control" header along with the picture, which is something I forgot to mention in my previous code, because I thought that it was not relevant. In fact, THIS IS the problem. So here is the code that really generates the bug: <? header("Content-type: image/gif"); header("Cache-Control: no-cache, must-revalidate"); $output="bird.gif"; // file name $fd = fopen($output,"r"); $filelength=filesize($output); $contents = fread($fd,$filelength); echo $contents; fclose($fd); ?> If you comment out the Cache-Control header line, everything works fine, so this is a workaround. However, I think that it is still a PHP bug, don't you ? Please try again (1 minute), I updated the report page: http://www.edenpics.com/pub/iebug/iebug2.phtml Thank you. ------------------------------------------------------------------------ [2003-04-05 11:13:29] sniper@php.net Disclaimer: the bird.gif _WAS_ jpeg before.. :) ------------------------------------------------------------------------ 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/23056 -- Edit this bug report at http://bugs.php.net/?id=23056&edit=1

« previous php.bugs (#37290) next »