aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authornodiscc <nodiscc@gmail.com>2015-03-05 13:33:30 +0100
committernodiscc <nodiscc@gmail.com>2015-03-05 13:33:30 +0100
commit403a19940961eaf3edae84c7e9c4fa0bd074e940 (patch)
tree62779b934ec9599ea4a4c94b264b738f77dd1a8d /index.php
parentad2a397c66a3da8061564602b43db6f2002f0064 (diff)
downloadShaarli-403a19940961eaf3edae84c7e9c4fa0bd074e940.tar.gz
Shaarli-403a19940961eaf3edae84c7e9c4fa0bd074e940.tar.zst
Shaarli-403a19940961eaf3edae84c7e9c4fa0bd074e940.zip
Improve annoying URL parameters cleaning:
* Use regular expressions to avoid suplicating params depending on their position in the URL (&param=,?param=) * Only remove the relevant URL pattern and don't remove following params, fixes https://github.com/shaarli/Shaarli/issues/136 * Credits to Marcus Rohrmoser (https://github.com/mro)
Diffstat (limited to 'index.php')
-rw-r--r--index.php5
1 files changed, 3 insertions, 2 deletions
diff --git a/index.php b/index.php
index cc3d7360..0b507b45 100644
--- a/index.php
+++ b/index.php
@@ -1642,11 +1642,12 @@ function renderPage()
1642 { 1642 {
1643 $url=$_GET['post']; 1643 $url=$_GET['post'];
1644 1644
1645
1645 // We remove the annoying parameters added by FeedBurner, GoogleFeedProxy, Facebook... 1646 // We remove the annoying parameters added by FeedBurner, GoogleFeedProxy, Facebook...
1646 $annoyingpatterns = array('&utm_source=', '?utm_source=', '#xtor=RSS-', '?fb_', '?__scoop', '#tk.rss_all?', '?utm_campaign=', '?utm_medium='); 1647 $annoyingpatterns = array('/[\?&]utm_source=[^&]*/', '/[\?&]utm_campaign=[^&]*/', '/[\?&]utm_medium=[^&]*/', '/#xtor=RSS-[^&]*/', '/[\?&]fb_[^&]*/', '/[\?&]__scoop[^&]*/', '/#tk\.rss_all\?/');
1647 foreach($annoyingpatterns as $pattern) 1648 foreach($annoyingpatterns as $pattern)
1648 { 1649 {
1649 $i=strpos($url,$pattern); if ($i!==false) $url=substr($url,0,$i); 1650 $url = preg_replace($pattern, "", $url);
1650 } 1651 }
1651 1652
1652 $link_is_new = false; 1653 $link_is_new = false;