khashnan / timthumb

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

PHP 5.3 - Ereg is deprecated #208

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Call the timthumb script on a php 5.3 install

What is the expected output? What do you see instead?
Should see the image and get nothing because there is error message before the 
image data in the file

What version of the product are you using? On what operating system?
PHP 5.3

Please provide any additional information below.
To fix the problem I replaced the ereg call by a preg_match. It only needs 
regexp delimiters, I choose # instead of / because of the // in http://

So simply replace the following (line 545) :
    if (preg_match('http://', $src) == true) {

        $url_info = parse_url ($src);

        $isAllowedSite = false;
        foreach ($allowedSites as $site) {
            if (preg_match($site, $url_info['host']) == true) {
                $isAllowedSite = true;
            }
        }

by

    if (preg_match('#http://#', $src) == true) {

        $url_info = parse_url ($src);

        $isAllowedSite = false;
        foreach ($allowedSites as $site) {
            if (preg_match("#".$site."#", $url_info['host']) == true) {
                $isAllowedSite = true;
            }
        }

Original issue reported on code.google.com by kaye...@gmail.com on 23 Jul 2011 at 1:45

GoogleCodeExporter commented 8 years ago
This was removed in April last year. I would highly recommend updating to the 
latest version of TimThumb - there have been a lot of improvements since then! 
:)

Original comment by BinaryMoon on 1 Aug 2011 at 10:31