From 622ccf1ae913bc7a995597908431f8d9d4a99690 Mon Sep 17 00:00:00 2001 From: Clemens Sahs Date: Sun, 20 Oct 2013 21:46:29 +0200 Subject: [PATCH] [zend/http] add a toggle property/methode for quoting the value --- library/Zend/Http/Header/SetCookie.php | 33 +++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/library/Zend/Http/Header/SetCookie.php b/library/Zend/Http/Header/SetCookie.php index 12422c7bbba..0841f2c5558 100644 --- a/library/Zend/Http/Header/SetCookie.php +++ b/library/Zend/Http/Header/SetCookie.php @@ -76,6 +76,13 @@ class SetCookie implements MultipleHeaderInterface */ protected $secure = null; + /** + * If the value need to be quoted or not + * + * @var bool|null + */ + protected $quoteFieldValue = null; + /** * @var bool|null */ @@ -197,6 +204,7 @@ public function getFieldName() } /** + * * @throws Exception\RuntimeException * @return string */ @@ -207,8 +215,11 @@ public function getFieldValue() } $value = urlencode($this->getValue()); + if ( $this->quoteFieldValue() ) { + $value = '"'. $value . '"'; + } - $fieldValue = $this->getName() . '=' . $value . ''; + $fieldValue = $this->getName() . '=' . $value; $version = $this->getVersion(); if ($version!==null) { @@ -424,6 +435,16 @@ public function setSecure($secure) return $this; } + /** + * @param bool $quotedValue + * @return SetCookie + */ + public function setQuoteFieldValue($quotedValue=false) + { + $this->quoteFieldValue = $quotedValue; + return $this; + } + /** * @return bool */ @@ -481,6 +502,16 @@ public function isSessionCookie() return ($this->expires === null); } + /** + * Check whether the cookie is a session cookie (has no expiry time set) + * + * @return bool + */ + public function quoteFieldValue() + { + return ($this->quoteFieldValue === true); + } + public function isValidForRequest($requestDomain, $path, $isSecure = false) { if ($this->getDomain() && (strrpos($requestDomain, $this->getDomain()) === false)) {