diff --git a/misc.php b/misc.php index 06a661b44..cbaff6130 100644 --- a/misc.php +++ b/misc.php @@ -145,11 +145,19 @@ if (strpos($referrer['host'], 'www.') === 0) $referrer['host'] = substr($referrer['host'], 4); + // Make sure the path component exists + if (!isset($referrer['path'])) + $referrer['path'] = ''; + $valid = parse_url(get_base_url()); // Remove www subdomain if it exists if (strpos($valid['host'], 'www.') === 0) $valid['host'] = substr($valid['host'], 4); + // Make sure the path component exists + if (!isset($valid['path'])) + $valid['path'] = ''; + if ($referrer['host'] == $valid['host'] && preg_match('%^'.preg_quote($valid['path'], '%').'/(.*?)\.php%i', $referrer['path'])) $redirect_url = $_SERVER['HTTP_REFERER']; }