From: VirtualTam Date: Sun, 12 Jul 2015 17:56:13 +0000 (+0200) Subject: Merge pull request #257 from ArthurHoaro/tag-http-referer X-Git-Tag: v0.5.0~6 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=5b0ebbc5de06b8a0e9679b78b45d0dc755db7986;hp=--cc;p=github%2Fshaarli%2FShaarli.git Merge pull request #257 from ArthurHoaro/tag-http-referer Prevent redirection loop everytime we rely on HTTP_REFERER --- 5b0ebbc5de06b8a0e9679b78b45d0dc755db7986 diff --cc index.php index b705146a,8e1552c1..bf0b99e0 --- a/index.php +++ 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']) {