meghlal / timthumb

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

Error when $_SERVER['DOCUMENT_ROOT'] is set to '/' #240

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Set the $_SERVER['DOCUMENT_ROOT'] to '/'.

What is the expected output? What do you see instead?
The TimThumb returns the following error message:

"Could not find your website document root and the file specified doesn't exist 
in timthumbs directory. We don't support serving files outside timthumb's 
directory without a document root for security reasons."

The problem is that on some virtual servers the $_SERVER['DOCUMENT_ROOT'] 
variable is set to '/'. In the line 808 the '/' is removed from the $docRoot:

if($docRoot){ $docRoot = preg_replace('/\/$/', '', $docRoot); }

So the $docRoot is empty, so the TimThumb throws an error about not finding the 
document root.

Is there any chance to make the TimThumb works with the 
$_SERVER['DOCUMENT_ROOT'] variable set to '/'?

Original issue reported on code.google.com by tosz...@gmail.com on 18 Aug 2011 at 9:42

GoogleCodeExporter commented 8 years ago
I've committed a possible fix for this. Would be interested to know how it goes.

Original comment by BinaryMoon on 21 Aug 2011 at 8:26

GoogleCodeExporter commented 8 years ago
Thank you, this is exactly what I did as a workaround. ;) Of course now it 
works as expected, but to be sure I'll check it on the other server tomorrow.

Original comment by tosz...@gmail.com on 21 Aug 2011 at 8:58

GoogleCodeExporter commented 8 years ago
The fix works on all my servers. I think this issue is now resolved and can be 
closed.

Original comment by tosz...@gmail.com on 26 Aug 2011 at 8:51

GoogleCodeExporter commented 8 years ago

Original comment by BinaryMoon on 3 Oct 2013 at 7:00