From: nodiscc Date: Thu, 5 Mar 2015 12:42:38 +0000 (+0100) Subject: Merge pull request #141 from nodiscc/cleanurl-filters X-Git-Tag: v0.0.44beta~15 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=01b8f52718f5136fb7de54e09b47ae4523aec9e8;hp=-c;p=github%2Fshaarli%2FShaarli.git Merge pull request #141 from nodiscc/cleanurl-filters Add URL cleaning filters + refactoring --- 01b8f52718f5136fb7de54e09b47ae4523aec9e8 diff --combined index.php index 890eb581,bc4fa1e4..a8326a2b --- a/index.php +++ b/index.php @@@ -1642,10 -1642,13 +1642,13 @@@ function renderPage( { $url=$_GET['post']; - // We remove the annoying parameters added by FeedBurner and GoogleFeedProxy (?utm_source=...) - $i=strpos($url,'&utm_source='); if ($i!==false) $url=substr($url,0,$i); - $i=strpos($url,'?utm_source='); if ($i!==false) $url=substr($url,0,$i); - $i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i); + + // We remove the annoying parameters added by FeedBurner, GoogleFeedProxy, Facebook... + $annoyingpatterns = array('/[\?&]utm_source=[^&]*/', '/[\?&]utm_campaign=[^&]*/', '/[\?&]utm_medium=[^&]*/', '/#xtor=RSS-[^&]*/', '/[\?&]fb_[^&]*/', '/[\?&]__scoop[^&]*/', '/#tk\.rss_all\?/', '/[\?&]action_ref_map=[^&]*/', '/[\?&]action_type_map=[^&]*/', '/[\?&]action_object_map=[^&]*/'); + foreach($annoyingpatterns as $pattern) + { + $url = preg_replace($pattern, "", $url); + } $link_is_new = false; $link = $LINKSDB->getLinkFromUrl($url); // Check if URL is not already in database (in this case, we will edit the existing link) @@@ -2125,8 -2128,11 +2128,8 @@@ function lazyThumbnail($url,$href=false $html=''; - // Lazy image (only loaded by JavaScript when in the viewport). - if (!empty($GLOBALS['disablejquery'])) // (except if jQuery is disabled) - $html.='