Selaa lähdekoodia

Favicon fix redirects

https://github.com/ArthurHoaro/favicon/pull/5/commits/92b42591591b4282261f21ed5ffa553f5e987a9d
Alexandre Alapetite 9 vuotta sitten
vanhempi
commit
f483a5e95b
3 muutettua tiedostoa jossa 6 lisäystä ja 0 poistoa
  1. 2 0
      lib/Favicon/DataAccess.php
  2. 3 0
      lib/Favicon/Favicon.php
  3. 1 0
      lib/favicons.php

+ 2 - 0
lib/Favicon/DataAccess.php

@@ -32,6 +32,8 @@ class DataAccess {
             array(
                 'http' => array(
                     'method' => 'GET',
+                    'follow_location' => 0,
+                    'max_redirects' => 1,
                     'timeout' => 10,
                     'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0; Favicon; +https://github.com/ArthurHoaro/favicon) Gecko/20100101 Firefox/32.0\r\n",
                 )

+ 3 - 0
lib/Favicon/Favicon.php

@@ -111,6 +111,9 @@ class Favicon
                 case '301':
                 case '302':
                     $url = isset($headers['location']) ? $headers['location'] : '';
+                    if (is_array($url)) {
+                        $url = end($url);
+                    }
                     break;
                 default:
                     $loop = FALSE;

+ 1 - 0
lib/favicons.php

@@ -14,6 +14,7 @@ function download_favicon($website, $dest) {
 	$favicon_getter = new \Favicon\Favicon();
 	$tmpPath = realpath(TMP_PATH);
 	$favicon_getter->setCacheDir($tmpPath);
+	$favicon_getter->setCacheTimeout(-1);
 	$favicon_path = $favicon_getter->get($website, \Favicon\FaviconDLType::DL_FILE_PATH);
 
 	return ($favicon_path != false && @rename($tmpPath . '/' . $favicon_path, $dest)) ||