ferenznetworks / timthumb

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

Files submitted without any slash at all fail. #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Lines 524-526

if(strpos($src, "/") == 0) {
    $src = substr($src, -(strlen($src) - 1));
}

Given the input "image.jpg", strpos will return false, which matches the 0
you are matching for. This is because, instead of strpos saying "there is a
slash in position 0", it is saying "there is no slash". It will be
evaluated as "if false == 0", which will come back as true. The if
statement will then execute, and it will cut the first character off $src,
despite it not being a slash. $src is now set to "mages.jpg".

Possible fix: Do an type-check (===) to make sure strpos is actually
returning an integer (0) as a position, and not a binary value (false) as a
report that there are no slashes.

Original issue reported on code.google.com by netri...@gmail.com on 10 May 2009 at 6:42

GoogleCodeExporter commented 8 years ago
Sorry, slight inconsistency: I used "image.jpg" at the beginning of my report, 
and
assumed "images.jpg" at the end. The $src would actually be set to "mage.jpg" 
after
execution.

Original comment by netri...@gmail.com on 10 May 2009 at 6:49

GoogleCodeExporter commented 8 years ago
a bit late but this is a valid report and I've now fixed it. Sorry it took so 
long to
sort it.

Original comment by BinaryMoon on 31 Dec 2009 at 5:02