From e58decc5f2dc39ca20b5831779d3ac483c038deb Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 21 Dec 2012 14:57:45 +0100 Subject: [PATCH] privacy_image_cache: If the cached file would be too long then don't cache it. --- privacy_image_cache/privacy_image_cache.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/privacy_image_cache/privacy_image_cache.php b/privacy_image_cache/privacy_image_cache.php index a47f0e1ac..3be426208 100644 --- a/privacy_image_cache/privacy_image_cache.php +++ b/privacy_image_cache/privacy_image_cache.php @@ -226,13 +226,21 @@ function privacy_image_cache_cachename($url, $writemode = false) { * @return boolean */ function privacy_image_cache_is_local_image($url) { - if ($url[0] == '/') return true; + if ($url[0] == '/') return true; + if (strtolower(substr($url, 0, 5)) == "data:") return true; + // Check if the cached path would be longer than 255 characters - apache doesn't like it + if (is_dir($_SERVER["DOCUMENT_ROOT"]."/privacy_image_cache")) { + $cachedurl = get_app()->get_baseurl()."/privacy_image_cache/". privacy_image_cache_cachename($url); + if (strlen($url) > 255) + return true; + } + // links normalised - bug #431 - $baseurl = normalise_link(get_app()->get_baseurl()); + $baseurl = normalise_link(get_app()->get_baseurl()); $url = normalise_link($url); - return (substr($url, 0, strlen($baseurl)) == $baseurl); + return (substr($url, 0, strlen($baseurl)) == $baseurl); } /**