rifanece / timthumb

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

Turn Absolute paths into relative paths #48

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
If you link to an image with an absolute path
http://website.com/timthumb.php?src=http://www.website.com/image.png note
the www triggers an error in many browsers as it's treated as an external
source.

I recommend some sort of preg_replace to ignore url and use ONLY relative
paths. Cross-domain linking doesn't work anyways, so why not have the
script ignore this and process as a relative link:

(this could obviously be simplified and improved, but this works and you
get the point: 

// sort out image source
$src = get_request("src", "");
$src = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*?)?)?)@',
'/', $src);

Original issue reported on code.google.com by clay.mci...@gmail.com on 2 Dec 2009 at 12:38

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
absolute paths should work fine now, as do some external domains :)

try the latest version and let me know how you get on.

Original comment by BinaryMoon on 31 Dec 2009 at 7:16

GoogleCodeExporter commented 8 years ago
Looks great, i like checkExternal() that will make it easy to extend and work 
with!
Thanks!

Original comment by clay.mci...@gmail.com on 31 Dec 2009 at 4:11

GoogleCodeExporter commented 8 years ago
Hi, 

I tried the above code, but still its not working. 

Original comment by Criz...@gmail.com on 30 Jan 2011 at 10:01

GoogleCodeExporter commented 8 years ago
Hi ! 

Unfortunetly my provider is not answering me (403 Forbidden) and I really need 
to use relative paths with the latest version. Could you help please ?

Thanks

Original comment by olivier....@gmail.com on 29 Oct 2013 at 6:55