Skip to content

Instantly share code, notes, and snippets.

@dol
Created September 9, 2011 10:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dol/1205916 to your computer and use it in GitHub Desktop.
ZF-11726 patch
Index: tests/Zend/Http/CookieJarTest.php
===================================================================
--- tests/Zend/Http/CookieJarTest.php (revision 24451)
+++ tests/Zend/Http/CookieJarTest.php (working copy)
@@ -91,7 +91,7 @@
$this->assertEquals(3, count($jar->getAllCookies()));
- $cookie_str = 'foo=bar;BOFH=Feature+was+not+beta+tested;time=1164234700;';
+ $cookie_str = 'foo=bar; BOFH=Feature+was+not+beta+tested; time=1164234700';
$this->assertEquals($cookie_str, $jar->getAllCookies(Zend_Http_CookieJar::COOKIE_STRING_CONCAT));
}
@@ -160,7 +160,7 @@
$jar->addCookie($cookie);
}
- $expected = 'name=Arthur;quest=holy+grail;swallow=african;';
+ $expected = 'name=Arthur; quest=holy+grail; swallow=african';
$real = $jar->getAllCookies(Zend_Http_CookieJar::COOKIE_STRING_CONCAT );
$this->assertEquals($expected, $real, 'Concatenated string is not as expected');
@@ -382,6 +382,9 @@
$cookies = $jar->getMatchingCookies('http://www.foo.com/path/file.txt', true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT);
$this->assertType('string', $cookies, '$cookies is expected to be a string');
+
+ $expected = 'foo1=bar1; foo2=bar2; foo4=bar4; foo7=bar7';
+ $this->assertEquals($expected, $cookies, 'Concatenated string is not as expected');
}
/**
Index: library/Zend/Http/CookieJar.php
===================================================================
--- library/Zend/Http/CookieJar.php (revision 24451)
+++ library/Zend/Http/CookieJar.php (working copy)
@@ -173,6 +173,9 @@
public function getAllCookies($ret_as = self::COOKIE_OBJECT)
{
$cookies = $this->_flattenCookiesArray($this->cookies, $ret_as);
+ if($ret_as == self::COOKIE_STRING_CONCAT) {
+ $cookies = rtrim($cookies, '; ');
+ }
return $cookies;
}
@@ -209,6 +212,10 @@
// Now, use self::_flattenCookiesArray again - only to convert to the return format ;)
$ret = $this->_flattenCookiesArray($ret, $ret_as);
+
+ if($ret_as == self::COOKIE_STRING_CONCAT) {
+ $ret = rtrim($ret, '; ');
+ }
return $ret;
}
@@ -272,11 +279,12 @@
if (is_array($ptr)) {
$ret = ($ret_as == self::COOKIE_STRING_CONCAT ? '' : array());
foreach ($ptr as $item) {
- if ($ret_as == self::COOKIE_STRING_CONCAT) {
- $ret .= $this->_flattenCookiesArray($item, $ret_as);
- } else {
- $ret = array_merge($ret, $this->_flattenCookiesArray($item, $ret_as));
- }
+ if ($ret_as == self::COOKIE_STRING_CONCAT) {
+ $postfix_combine = (!is_array($item) ? ' ' : '');
+ $ret .= $this->_flattenCookiesArray($item, $ret_as) . $postfix_combine;
+ } else {
+ $ret = array_merge($ret, $this->_flattenCookiesArray($item, $ret_as));
+ }
}
return $ret;
} elseif ($ptr instanceof Zend_Http_Cookie) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment