From 107008cb15b0679f7c6c0d3f264231e0f098745f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 4 Mar 2009 14:06:15 +0300 Subject: [PATCH] add patch for better favicon fetching (closes #231) --- functions.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/functions.php b/functions.php index 648ab343..60a4a4bf 100644 --- a/functions.php +++ b/functions.php @@ -395,10 +395,14 @@ $faviconURL = $urlParts['scheme'].'://'.$urlParts['host'].$linkUrl; } else if (substr($linkUrl, 0, 7) == 'http://') { $faviconURL = $linkUrl; - } else if (substr($url, -1, 1) == '/') { - $faviconURL = $url.$linkUrl; } else { - $faviconURL = $url.'/'.$linkUrl; + $pos = strrpos($url, "/"); + // no "/" in url or "/" is part of "://" + if ($pos === false || $pos == (strpos($url, "://")+2)) { + $faviconURL = $url.'/'.$linkUrl; + } else { + $faviconURL = substr($url, 0, $pos+1).$linkUrl; + } } } else { @@ -454,7 +458,7 @@ $http_response = fgets( $socket, 22 ); - $responses = "/(200 OK)|(30[0-9] Moved)/"; + $responses = "/(200 OK)|(30[123])/"; if ( preg_match($responses, $http_response) ) { fclose($socket); return true; -- 2.39.5