public
Created

ZF-11726 patch

  • Download Gist
ZF-11726.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
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) {

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.