Skip to content

Commit

Permalink
[zend/http] add a toggle property/methode for quoting the value
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemensSahs committed Oct 20, 2013
1 parent e70d92a commit 622ccf1
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion library/Zend/Http/Header/SetCookie.php
Expand Up @@ -76,6 +76,13 @@ class SetCookie implements MultipleHeaderInterface
*/
protected $secure = null;

/**
* If the value need to be quoted or not
*
* @var bool|null
*/

This comment has been minimized.

Copy link
@Maks3w

Maks3w Oct 21, 2013

Set false by default

This comment has been minimized.

Copy link
@Maks3w

Maks3w Oct 21, 2013

Sorry, true for preserve the BC

protected $quoteFieldValue = null;

/**
* @var bool|null
*/
Expand Down Expand Up @@ -197,6 +204,7 @@ public function getFieldName()
}

/**
*
* @throws Exception\RuntimeException
* @return string
*/
Expand All @@ -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) {
Expand Down Expand Up @@ -424,6 +435,16 @@ public function setSecure($secure)
return $this;
}

/**
* @param bool $quotedValue
* @return SetCookie
*/

This comment has been minimized.

Copy link
@Maks3w

Maks3w Oct 21, 2013

Remove the default value

public function setQuoteFieldValue($quotedValue=false)
{

This comment has been minimized.

Copy link
@Maks3w

Maks3w Oct 21, 2013

cast to boolean before assign the value

$this->quoteFieldValue = $quotedValue;
return $this;
}

/**
* @return bool
*/
Expand Down Expand Up @@ -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()

This comment has been minimized.

Copy link
@Maks3w

Maks3w Oct 21, 2013

hasQuote....

{
return ($this->quoteFieldValue === true);

This comment has been minimized.

Copy link
@Maks3w

Maks3w Oct 21, 2013

Return the value of the property. Due all previous feedback the value is always a boolean

}

public function isValidForRequest($requestDomain, $path, $isSecure = false)
{
if ($this->getDomain() && (strrpos($requestDomain, $this->getDomain()) === false)) {
Expand Down

0 comments on commit 622ccf1

Please sign in to comment.