View Issue Details

IDProjectCategoryView StatusLast Update
0011101mantisbtattachmentspublic2010-02-22 14:34
Reporterjoshribakoff Assigned Todhx  
PriorityhighSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.0rc2 
Target Version1.2.0Fixed in Version1.2.0 
Summary0011101: Headers are sent too late in file_download.php (after content has been written)
Description

In firefox, I am unable to view attachments. It looks like the file is trying to be displayed as plaintext, I get a few pages of "binary" data, followed by an error:

<p style="color:red">SYSTEM WARNING: Cannot modify header information - headers already sent by (output started at /home/ins09/public_html/tools/mantisbt/file_download.php:172)</p>

If I right click and save link as, I can view the photo. However I attempt to edit my saved .jpg in EditPlus, I can see the PHP error message at the end still.

I further narrowed down the problem to your if( $finfo_available). There should be some action taken if the finfo is not available, like prompt the user to download the file, or inform them to enable the finfo extension.

Steps To Reproduce

Disable finfo extension and try to view a jpeg attachment in firefox.

Additional Information

My temporary fix was to hard code a content-type header in and 'else', as well as commenting out the Content-Length line ( to fix the headers after output). I suppose I could install finfo also.

Attached is the Waterfall.jpg with the error message as plain text inside of the file. Open inside of notepad or EditPlus and scroll to the end of the file.

TagsNo tags attached.
Attached Files
Waterfall.jpg (287,811 bytes)   
Waterfall.jpg (287,811 bytes)   

Relationships

related to 0011045 closedvboctor Display of attached files 

Activities

vboctor

vboctor

2009-10-31 00:48

manager   ~0023507

Is this a duplicate of 0011045?

joshribakoff

joshribakoff

2009-10-31 01:21

reporter   ~0023508

I would say part of it may duplicate that issue, but the "output already started" error is new.

joshribakoff

joshribakoff

2009-10-31 01:23

reporter   ~0023509

echo $v_content;
}
// header( 'Content-Length: ' . $v_filesize );

This is lines 172- 174, I commented out the last line. Before that was causing the error.

vboctor

vboctor

2009-10-31 04:20

manager   ~0023510

  1. What kind of attachment storage method do you use?
  2. Did you check the commit code at the end of the page on the issue I referred to? Don't look at the comments.

I don't think the checked-in code has the problem you are referring to. If you try your attachment on this bug tracker, it works fine.

rledford

rledford

2010-01-04 19:12

reporter   ~0024030

Last edited: 2010-01-04 19:13

See note 0011202:0024010.
I applied changes recommended on 0011045 and 0011202 and had independent verification that the issue described here was resolved.
Today the issue is back and I cannot find any related changes to our Mantis install. The only change to the system is that Apache was restarted.

I am running Mantis on Windows Server 2003 with MySQL.

rledford

rledford

2010-01-04 23:28

reporter   ~0024032

Last edited: 2010-01-04 23:31

I corrected this issue by applying the change noted in 0011101:0023509.

dhx

dhx

2010-01-05 00:27

reporter   ~0024034

Already fixed as part of http://git.mantisbt.org/?p=mantisbt.git;a=commitdiff;h=b341ca89c83b9d906b229d289c35dfcc1185b034 and http://git.mantisbt.org/?p=mantisbt.git;a=commitdiff;h=be57bb8c86e716c6f13c676a0724b7a6338b9e5f

I didn't see this bug when I fixed those issues, which is why they weren't linked to this bug earlier.

Related Changesets

MantisBT: master-1.2.x ff2d2ab8

2009-10-27 05:24

dhx


Details Diff
Send headers before output buffer is flushed for file_download.php

Content-* headers and etc should be sent before the output buffer is
flushed at the start of file transfers. These headers have also been
reordered so they're grouped together more logically.

Also inline_file_exts can now be blank without the 'gif' attachment
being forcefully added by Mantis.
Affected Issues
0011101
mod - file_download.php Diff File

MantisBT: master b341ca89

2009-10-27 05:24

dhx


Details Diff
Send headers before output buffer is flushed for file_download.php

Content-* headers and etc should be sent before the output buffer is
flushed at the start of file transfers. These headers have also been
reordered so they're grouped together more logically.

Also inline_file_exts can now be blank without the 'gif' attachment
being forcefully added by Mantis.
Affected Issues
0011101
mod - file_download.php Diff File

MantisBT: master-1.2.x f06ecd68

2009-10-28 19:06

dhx


Details Diff
ob_end_clean should be called BEFORE headers are sent

Follow-up to commit b341ca89c83b9d906b229d289c35dfcc1185b034

ob_end_clean throws away the output buffer instead of flushing it to the
client. Therefore we should call this BEFORE the file download headers
are sent to the client or else these headers could potentially be thrown
away/lost.

Note to self: don't rely upon incorrect comments in the code that tell
you ob_end_clean flushes the buffer... look it up in the PHP manual!
Affected Issues
0011101
mod - file_download.php Diff File

MantisBT: master be57bb8c

2009-10-28 19:06

dhx


Details Diff
ob_end_clean should be called BEFORE headers are sent

Follow-up to commit b341ca89c83b9d906b229d289c35dfcc1185b034

ob_end_clean throws away the output buffer instead of flushing it to the
client. Therefore we should call this BEFORE the file download headers
are sent to the client or else these headers could potentially be thrown
away/lost.

Note to self: don't rely upon incorrect comments in the code that tell
you ob_end_clean flushes the buffer... look it up in the PHP manual!
Affected Issues
0011101
mod - file_download.php Diff File