]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #257 from ArthurHoaro/tag-http-referer
authorVirtualTam <tamisier.aurelien@gmail.com>
Sun, 12 Jul 2015 17:56:13 +0000 (19:56 +0200)
committerVirtualTam <tamisier.aurelien@gmail.com>
Sun, 12 Jul 2015 17:56:13 +0000 (19:56 +0200)
Prevent redirection loop everytime we rely on HTTP_REFERER

1  2 
index.php

diff --cc index.php
index b705146a7ccf7895bbec94abc51882f2d4f9ac8b,8e1552c1b6c388e24d73aaffb7266d7416fb01c0..bf0b99e043b7492f8402cd2c62aa8b5b29b13f66
+++ b/index.php
@@@ -1120,13 -1099,14 +1120,18 @@@ function renderPage(
          if (empty($_SERVER['HTTP_REFERER'])) { header('Location: ?searchtags='.urlencode($_GET['addtag'])); exit; } // In case browser does not send HTTP_REFERER
          parse_str(parse_url($_SERVER['HTTP_REFERER'],PHP_URL_QUERY), $params);
  
+         // Prevent redirection loop
+         if (isset($params['addtag'])) {
+             unset($params['addtag']);
+         }
          // Check if this tag is already in the search query and ignore it if it is.
          // Each tag is always separated by a space
 -        $current_tags = explode(' ', $params['searchtags']);
 +        if (isset($params['searchtags'])) {
 +            $current_tags = explode(' ', $params['searchtags']);
 +        } else {
 +            $current_tags = array();
 +        }
          $addtag = true;
          foreach ($current_tags as $value) {
              if ($value === $_GET['addtag']) {