crnr / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

Have error image set but page throwing different error and not showing error image #262

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. set error default image
2. load page with image on server NOT allowed
3. no default shown just another error message saying that image with external 
src can't be shown because it has errors.
4. Error message has an image header so it is rendered as an image

What is the expected output? What do you see instead?
On error I expected the error image to be shown

What version of the product are you using? On what operating system?
script version is 2.8 wordpress v 3.2.1

Please provide any additional information below.

Example url: 
http://www.dougberger.net/archive/2008/10/john-mccains-palling-around-with-charl
es-keating-who-defrauded-tax-payers-in-late-1980s.html

I have this set in the config php:

if(! defined('ERROR_IMAGE') )   define ('ERROR_IMAGE', 
'http://www.dougberger.net/wp-content/uploads/2011/08/dougsviews.jpg');

Image is valid since I use it as my standard related default image and it shows 
on the example page.

See the attached image to see the new error message I get when right clicking 
and viewing image on example page

Here is the server error log:

[Thu Sep 08 16:02:24 2011] [error] [client 65.24.135.240] TimThumb Debug line 
1069 [0.001299 : 0.000142]: Is a request for an external URL: 
http://punditkitchen.wordpress.com/files/2008/09/political-pictures-barack-obama
-chill-out-got-this.jpg, referer: 
http://www.dougberger.net/archive/2008/10/john-mccains-palling-around-with-charl
es-keating-who-defrauded-tax-payers-in-late-1980s.html
[Thu Sep 08 16:02:24 2011] [error] [client 65.24.135.240] TimThumb Debug line 
1069 [0.001326 : 0.000022]: Fetching only from selected external sites is 
enabled., referer: 
http://www.dougberger.net/archive/2008/10/john-mccains-palling-around-with-charl
es-keating-who-defrauded-tax-payers-in-late-1980s.html
[Thu Sep 08 16:02:24 2011] [error] [client 65.24.135.240] TimThumb Debug line 
1069 [0.001428 : 0.000099]: Adding error message: You may not fetch images from 
that site. To enable this site in timthumb, you can either add it to 
$ALLOWED_SITES and set ALLOW_EXTERNAL=true. Or you can set 
ALLOW_ALL_EXTERNAL_SITES=true, depending on your security needs., referer: 
http://www.dougberger.net/archive/2008/10/john-mccains-palling-around-with-charl
es-keating-who-defrauded-tax-payers-in-late-1980s.html

Original issue reported on code.google.com by voncadf...@gmail.com on 8 Sep 2011 at 11:19

Attachments:

GoogleCodeExporter commented 8 years ago
I hope this wasn't overlooked or maybe I wasn't clear. I set an image default 
to be shown if there is an error - for example if the first image is on a 
server not in the allowed domain list.

I get the error but the error image isn't shown. It is the same as the default 
image used for the related posts but error message says image is invalid

Original comment by voncadf...@gmail.com on 20 Sep 2011 at 9:07

GoogleCodeExporter commented 8 years ago
I had a similar problem and managed to resolve it a few minutes ago. The 
attached file has a file size of 12.6Kb and can be confirmed using stat in 
linux:
File: `no_image.png'
  Size: 12230       Blocks: 24         IO Block: 4096   regular file
...

And the correct type is being detected as well if I use file on the CLI: 
no_image.png: PNG image data, 395 x 395, 8-bit/color RGB, non-interlaced.

The funny thing is if you try and view the file size with something like 
imagemagick GUI it has a file size of 0 bytes. When trying to access the file 
via timthumb the script is setting the header "Content-Length" to 0 and the 
browser interprets that the file is truncated or incomplete, but the file is 
actually fine if you load it up in the browser.

With the latest version of Timthumb I changed line 1224 from:
header ('Content-Length: ' . filesize($file) );

to:

if(filesize($file)) {
    header ('Content-Length: ' . filesize($file) );
}

This solves the issue for valid images but might not be an ideal workaround if 
an image really is 0 bytes.

Original comment by and...@gmail.com on 14 Nov 2012 at 1:57

Attachments: