FO: Fix #PSCFV-5800 don't send any cookie on canonical redirection

This commit is contained in:
Rémi Gaillard
2012-11-23 15:44:23 +01:00
parent 67be4309d2
commit f5d4fbccfd
2 changed files with 12 additions and 1 deletions
+9 -1
View File
@@ -51,6 +51,8 @@ class CookieCore
protected $_iv;
protected $_modified = false;
protected $_allow_writing;
/**
* Get data if the cookie exists and else initialize an new one
@@ -71,6 +73,7 @@ class CookieCore
$this->_key = _COOKIE_KEY_;
$this->_iv = _COOKIE_IV_;
$this->_domain = $this->getDomain($shared_urls);
$this->_allow_writing = true;
if (Configuration::get('PS_CIPHER_ALGORITHM'))
$this->_cipherTool = new Rijndael(_RIJNDAEL_KEY_, _RIJNDAEL_IV_);
else
@@ -78,6 +81,11 @@ class CookieCore
$this->update();
}
public function disallowWriting()
{
$this->_allow_writing = false;
}
protected function getDomain($shared_urls = null)
{
$r = '!(?:(\w+)://)?(?:(\w+)\:(\w+)@)?([^/:]+)?(?:\:(\d*))?([^#?]+)?(?:\?([^#]+))?(?:#(.+$))?!i';
@@ -325,7 +333,7 @@ class CookieCore
*/
public function write()
{
if (!$this->_modified || headers_sent())
if (!$this->_modified || headers_sent() || !$this->_allow_writing)
return;
$cookie = '';
+3
View File
@@ -657,6 +657,9 @@ class FrontControllerCore extends Controller
else
$final_url = preg_replace('/^([^?]*)?.*$/', '$1', $canonical_url);
// Don't send any cookie
Context::getContext()->cookie->disallowWriting();
if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_ && $_SERVER['REQUEST_URI'] != __PS_BASE_URI__)
die('[Debug] This page has moved<br />Please use the following URL instead: <a href="'.$final_url.'">'.$final_url.'</a>');