#41491 [NEW]: header() adds extra x'200A' space/LF to start of file
| From: | jeff at pointhere dot net | Date: | Thu, 24 May 2007 15:50:34 +0000 |
| Subject: | #41491 [NEW]: header() adds extra x'200A' space/LF to start of file | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-112997@lists.php.net to get a copy of this message | ||
From: jeff at pointhere dot net
Operating system: Sun OS 5.10 (Solaris 10)
PHP version: 5.2.2
PHP Bug Type: HTTP related
Bug description: header() adds extra x'200A' space/LF to start of file
Description:
------------
When using the header() function to prepend a text file so that a user can
save a downloaded file, the resulting file has two extra characters on the
front of the file (hex '200A' - space and line-feed). When header()
functions are removed, the file appears to load into the browser correctly.
Reproduce code:
---------------
// Start sending the file
ob_start();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: text/plain");
header("Content-Length: " . $filesize);
header("Content-Disposition: attachment; filename=\"" . $filename .
"\"");
header("Content-Transfer-Encoding: 7bit");
echo($cardprint_file);
ob_end_flush();
exit;
Expected result:
----------------
The user's browser should open a window that asks to Open, Save or Cancel
the download. When saving or opening the file the contents of
$cardprint_file should be the ONLY contents (the contents were verified to
be correct with the var_dump command).
Actual result:
--------------
The first two characters in the file (which translate to a blank line) are
an ASCII hex 20 (space) and an ASCII hex 0A (Line feed).
--
Edit bug report at http://bugs.php.net/?id=41491&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41491&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41491&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41491&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41491&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41491&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41491&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41491&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41491&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41491&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41491&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41491&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41491&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41491&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41491&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41491&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41491&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41491&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41491&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41491&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41491&r=mysqlcfg