|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-02-16 11:16 UTC] derick@php.net
[2006-02-16 11:48 UTC] smartbitcalc at hotmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 21:00:02 2025 UTC |
Description: ------------ Win32 GD imagepng() outputs bad data to the browser when the source or any included file has extraneous whitespace surrounding the <?php ?> tags. Tested Systems: Windows 98 SE PHP 5CVS2006-Feb-15(snap), PHP 5.1.2, PHP 4.3.4RC1 MSIE 5.0, Firefox 1.0.6 Windows XP Home SP1 PHP 4.3.11, MSIE 6.0 (breaks on space|crlf before <?php, space+crlf after ?>) Reproduce code: --------------- test.php: <?php // include("testinc.php"); $text = "Happy Happy Joy Joy"; $test = ImageCreate(160,24); ImageFill($test,0,0,ImageColorAllocate($test,0,0,0)); ImageString($test,4,4,4,$text,ImageColorAllocate($test,255,255,255)); header("Content-type: image/png"); imagepng($test); ?> testinc.php: <?php $gettysburg = "Four score and seven years ago..."; ?>_ <-- note: insert whitespace (0x20) after closing tag Expected result: ---------------- Run test.php as listed and the browser displays the image as expected. Uncomment the include file, save and run test.php again, and the browser displays a "broken picture" icon. If you remove the trailing space from testinc.php the browser displays the image, but if you insert a space or a carriage return before the opening tag of either file, the image is "broken" again. (Firefox gives you the message 'The image "http://localhost/test.php" cannot be displayed, because it contains errors' rather than a broken image icon, but the cause and effect are the same.) Actual result: -------------- Speculation: the problem is actually intermittent (or appears to be) but at least this is verifiable. I have a hunch that the extraneous whitespace is somehow finding its way to the output buffer as the source is being parsed.