php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28863 Weird Bug with imagepng (including special chars)
Submitted: 2004-06-21 08:53 UTC Modified: 2004-06-23 22:33 UTC
From: jsgoupil at lookstrike dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.0.0RC3 OS: WinXP
Private report: No CVE-ID: None
 [2004-06-21 08:53 UTC] jsgoupil at lookstrike dot com
Description:
------------
You will say that i'm really weird to do that, but i don't know how that happen :

I check into one file, i found the following chars :
chr(239) + chr(187) + chr(191)
Keep the order ! it's important !
(I found that in one of my file, but dont ask me why !)

If you try to include this kind of file before doing a PNG image, you will get a WRONG png format. (Starting with "?PNG"...)

The chars above can't be read under Notepad, neither under IE (perhaps because i'm under WinXP). It can't be deleted from NotePad (if you clear the file completly, the file will still have 3bytes undeletable) but you can delete it with wordpad...

I search really a lot of time to found that problem... because I was including a file that had that kind of chars...

Reproduce code:
---------------
VBScript to put chr into file

Open "test1.php" For Output As #1
Print #1, Chr(239) + Chr(187) + Chr(191)
Close #1


PHP Script :
<?php
include("test3.php");
$im = imagecreate(1024, 1024)
or die("Can't Initialize the GD Libraty");
imagecolorallocate($im,255,255,255);
imagepng($im);
?>

Expected result:
----------------
Supposed return some chars in IE and after the PNG format like : "?PNG ".....

Because normally, if you do a
echo "a";
imagepng($im);
You will receive the "a" and after the PNG format in text.

Actual result:
--------------
Under WinXP I receive directly the wrong PNG format... like : "?PNG  IHDRE&#1273;?PLTE?&#283;&#512;?IDATx?&#53313;? ?@&#61828;?!&#1190;IEND?B`?"

(Without ")

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-21 08:56 UTC] jsgoupil at lookstrike dot com
the reproduce code... supposed to be the same test file... so Open "test1.php"... and include("test1.php");

:)
 [2004-06-23 22:29 UTC] moriyoshi@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

imagettftext() expects UTF-8 for the encoding in which the text    is stored.

See: http://www.voltex.jp/articles/imagettf_m10n/

 [2004-06-23 22:33 UTC] moriyoshi@php.net
The previous comment is just a wrong post, so ignore that...

Most likely the file you included in the main script includes a   UTF-8 BOM mark at the beginning. Use the suitable editor / encoding to compose PHP scripts.



 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 15 05:01:31 2024 UTC