diff options
Diffstat (limited to 'libs/Zend/Http/Cookie.php')
-rw-r--r-- | libs/Zend/Http/Cookie.php | 62 |
1 files changed, 23 insertions, 39 deletions
diff --git a/libs/Zend/Http/Cookie.php b/libs/Zend/Http/Cookie.php index 49d2ff6ad8..d8e278898a 100644 --- a/libs/Zend/Http/Cookie.php +++ b/libs/Zend/Http/Cookie.php @@ -16,15 +16,15 @@ * @category Zend * @package Zend_Http * @subpackage Cookie - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) - * @version $Id: Cookie.php 21020 2010-02-11 17:27:23Z shahar $ + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @version $Id: Cookie.php 17124 2009-07-26 09:46:42Z shahar $ * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * @see Zend_Uri_Http */ -// require_once 'Zend/Uri/Http.php'; +require_once 'Zend/Uri/Http.php'; /** @@ -41,7 +41,7 @@ * * @category Zend * @package Zend_Http - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Http_Cookie @@ -89,13 +89,6 @@ class Zend_Http_Cookie protected $secure; /** - * Whether the cookie value has been encoded/decoded - * - * @var boolean - */ - protected $encodeValue; - - /** * Cookie object constructor * * @todo Add validation of each one of the parameters (legal domain, etc.) @@ -110,17 +103,17 @@ class Zend_Http_Cookie public function __construct($name, $value, $domain, $expires = null, $path = null, $secure = false) { if (preg_match("/[=,; \t\r\n\013\014]/", $name)) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("Cookie name cannot contain these characters: =,; \\t\\r\\n\\013\\014 ({$name})"); } if (! $this->name = (string) $name) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception('Cookies must have a name'); } if (! $this->domain = (string) $domain) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception('Cookies must have a domain'); } @@ -234,7 +227,7 @@ class Zend_Http_Cookie // Make sure we have a valid Zend_Uri_Http object if (! ($uri->valid() && ($uri->getScheme() == 'http' || $uri->getScheme() =='https'))) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception('Passed URI is not a valid HTTP or HTTPS URI'); } @@ -265,10 +258,7 @@ class Zend_Http_Cookie */ public function __toString() { - if ($this->encodeValue) { - return $this->name . '=' . urlencode($this->value) . ';'; - } - return $this->name . '=' . $this->value . ';'; + return $this->name . '=' . urlencode($this->value) . ';'; } /** @@ -276,16 +266,14 @@ class Zend_Http_Cookie * (for example the value of the Set-Cookie HTTP header) * * @param string $cookieStr - * @param Zend_Uri_Http|string $refUri Reference URI for default values (domain, path) - * @param boolean $encodeValue Weither or not the cookie's value should be - * passed through urlencode/urldecode + * @param Zend_Uri_Http|string $ref_uri Reference URI for default values (domain, path) * @return Zend_Http_Cookie A new Zend_Http_Cookie object or false on failure. */ - public static function fromString($cookieStr, $refUri = null, $encodeValue = true) + public static function fromString($cookieStr, $ref_uri = null) { // Set default values - if (is_string($refUri)) { - $refUri = Zend_Uri_Http::factory($refUri); + if (is_string($ref_uri)) { + $ref_uri = Zend_Uri_Http::factory($ref_uri); } $name = ''; @@ -302,14 +290,12 @@ class Zend_Http_Cookie // Get the name and value of the cookie list($name, $value) = explode('=', trim(array_shift($parts)), 2); $name = trim($name); - if ($encodeValue) { - $value = urldecode(trim($value)); - } + $value = urldecode(trim($value)); // Set default domain and path - if ($refUri instanceof Zend_Uri_Http) { - $domain = $refUri->getHost(); - $path = $refUri->getPath(); + if ($ref_uri instanceof Zend_Uri_Http) { + $domain = $ref_uri->getHost(); + $path = $ref_uri->getPath(); $path = substr($path, 0, strrpos($path, '/')); } @@ -334,7 +320,7 @@ class Zend_Http_Cookie * * @see Zend_Date */ - // require_once 'Zend/Date.php'; + require_once 'Zend/Date.php'; $expireDate = new Zend_Date($v); $expires = $expireDate->getTimestamp(); @@ -356,9 +342,7 @@ class Zend_Http_Cookie } if ($name !== '') { - $ret = new self($name, $value, $domain, $expires, $path, $secure); - $ret->encodeValue = ($encodeValue) ? true : false; - return $ret; + return new self($name, $value, $domain, $expires, $path, $secure); } else { return false; } @@ -377,12 +361,12 @@ class Zend_Http_Cookie public static function matchCookieDomain($cookieDomain, $host) { if (! $cookieDomain) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("\$cookieDomain is expected to be a cookie domain"); } if (! $host) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("\$host is expected to be a host name"); } @@ -410,12 +394,12 @@ class Zend_Http_Cookie public static function matchCookiePath($cookiePath, $path) { if (! $cookiePath) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("\$cookiePath is expected to be a cookie path"); } if (! $path) { - // require_once 'Zend/Http/Exception.php'; + require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("\$path is expected to be a host name"); } |