Try to limit max favicon size, don't store current/old in a var.

This commit is contained in:
wn_ 2021-02-21 23:30:31 +00:00
parent cb401af6f6
commit 02a9485966
3 changed files with 12 additions and 4 deletions

View File

@ -1652,15 +1652,19 @@ class RSSUtils {
} }
// Limiting to "image" type misses those served with text/plain // Limiting to "image" type misses those served with text/plain
$contents = UrlHelper::fetch(['url' => $favicon_url]); // , "image"); $contents = UrlHelper::fetch([
'url' => $favicon_url,
'max_size' => MAX_FAVICON_FILE_SIZE,
//'type' => 'image',
]);
if (!$contents) { if (!$contents) {
Debug::log("fetching favicon $favicon_url failed", Debug::$LOG_VERBOSE); Debug::log("fetching favicon $favicon_url failed", Debug::$LOG_VERBOSE);
return false; return false;
} }
$original_contents = file_exists($icon_file) ? file_get_contents($icon_file) : null; $original_contents_md5 = file_exists($icon_file) ? md5_file($icon_file) : null;
if ($original_contents) { if ($original_contents_md5) {
if (strcmp($contents, $original_contents) === 0) { if (md5($contents) == $original_contents_md5) {
Debug::log("favicon content has not changed", Debug::$LOG_VERBOSE); Debug::log("favicon content has not changed", Debug::$LOG_VERBOSE);
return $icon_file; return $icon_file;
} }

View File

@ -68,6 +68,8 @@
// do not cache files larger than that (bytes) // do not cache files larger than that (bytes)
define_default('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024); define_default('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024);
// do not download general files larger than that (bytes) // do not download general files larger than that (bytes)
define_default('MAX_FAVICON_FILE_SIZE', 1*1024*1024);
// do not download favicon files larger than that (bytes)
define_default('CACHE_MAX_DAYS', 7); define_default('CACHE_MAX_DAYS', 7);
// max age in days for various automatically cached (temporary) files // max age in days for various automatically cached (temporary) files
define_default('MAX_CONDITIONAL_INTERVAL', 3600*12); define_default('MAX_CONDITIONAL_INTERVAL', 3600*12);

View File

@ -27,6 +27,8 @@
// do not cache files larger than that (bytes) // do not cache files larger than that (bytes)
define('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024); define('MAX_DOWNLOAD_FILE_SIZE', 16*1024*1024);
// do not download general files larger than that (bytes) // do not download general files larger than that (bytes)
define('MAX_FAVICON_FILE_SIZE', 1*1024*1024);
// do not download favicon files larger than that (bytes)
define('CACHE_MAX_DAYS', 7); define('CACHE_MAX_DAYS', 7);
// max age in days for various automatically cached (temporary) files // max age in days for various automatically cached (temporary) files
define('MAX_CONDITIONAL_INTERVAL', 3600*12); define('MAX_CONDITIONAL_INTERVAL', 3600*12);