aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2015-11-04 19:53:59 +0100
committerArthurHoaro <arthur@hoa.ro>2015-11-04 19:53:59 +0100
commitd01c234235411bafb97661d335fcb6ea1e67ffbc (patch)
tree0cade3729406e61435e63b7b27e4957f8a2abd47 /application
parent38bedfbbcdd2a40e9f04f5753e0fd6f4fd513c21 (diff)
downloadShaarli-d01c234235411bafb97661d335fcb6ea1e67ffbc.tar.gz
Shaarli-d01c234235411bafb97661d335fcb6ea1e67ffbc.tar.zst
Shaarli-d01c234235411bafb97661d335fcb6ea1e67ffbc.zip
Fixes #356
* adding a link should return added link's hash * allow redirection relative urls in generateLocation
Diffstat (limited to 'application')
-rwxr-xr-xapplication/Utils.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/application/Utils.php b/application/Utils.php
index 1422961d..120333c5 100755
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -97,12 +97,12 @@ function checkDateFormat($format, $string)
97 */ 97 */
98function generateLocation($referer, $host, $loopTerms = array()) 98function generateLocation($referer, $host, $loopTerms = array())
99{ 99{
100 $final_referer = '?'; 100 $finalReferer = '?';
101 101
102 // No referer if it contains any value in $loopCriteria. 102 // No referer if it contains any value in $loopCriteria.
103 foreach ($loopTerms as $value) { 103 foreach ($loopTerms as $value) {
104 if (strpos($referer, $value) !== false) { 104 if (strpos($referer, $value) !== false) {
105 return $final_referer; 105 return $finalReferer;
106 } 106 }
107 } 107 }
108 108
@@ -111,11 +111,12 @@ function generateLocation($referer, $host, $loopTerms = array())
111 $host = substr($host, 0, $pos); 111 $host = substr($host, 0, $pos);
112 } 112 }
113 113
114 if (!empty($referer) && strpos(parse_url($referer, PHP_URL_HOST), $host) !== false) { 114 $refererHost = parse_url($referer, PHP_URL_HOST);
115 $final_referer = $referer; 115 if (!empty($referer) && (strpos($refererHost, $host) !== false || startsWith('?', $refererHost))) {
116 $finalReferer = $referer;
116 } 117 }
117 118
118 return $final_referer; 119 return $finalReferer;
119} 120}
120 121
121/** 122/**