Browse Source

Merge pull request #11121 from supermanner/fix-cookie-collection

Fix CookieCollection::parseSetCookieHeader when the cookie has proper…
Mark Story 8 years ago
parent
commit
95b0de3e97

+ 1 - 1
src/Http/Cookie/CookieCollection.php

@@ -357,7 +357,7 @@ class CookieCollection implements IteratorAggregate, Countable
                     continue;
                 }
                 $key = strtolower($key);
-                if (!strlen($cookie[$key])) {
+                if (array_key_exists($key, $cookie) && !strlen($cookie[$key])) {
                     $cookie[$key] = $value;
                 }
             }

+ 2 - 1
tests/TestCase/Http/Cookie/CookieCollectionTest.php

@@ -436,12 +436,13 @@ class CookieCollectionTest extends TestCase
         $header = [
             'http=name; HttpOnly; Secure;',
             'expires=expiring; Expires=Wed, 15-Jun-2022 10:22:22; Path=/api; HttpOnly; Secure;',
-            'expired=expired; Expires=Wed, 15-Jun-2015 10:22:22;',
+            'expired=expired; version=1; Expires=Wed, 15-Jun-2015 10:22:22;',
         ];
         $cookies = CookieCollection::createFromHeader($header);
         $this->assertCount(3, $cookies);
         $this->assertTrue($cookies->has('http'));
         $this->assertTrue($cookies->has('expires'));
+        $this->assertFalse($cookies->has('version'));
         $this->assertTrue($cookies->has('expired'), 'Expired cookies should be present');
     }