Skip to content

Commit 277e37e

Browse files
committed
parse cookie values containing the equal sign
1 parent 04c67e6 commit 277e37e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Symfony/Component/HttpFoundation/Cookie.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ public static function fromString($cookie, $decode = false)
6262
$part = array_shift($parts);
6363

6464
$name = $decode ? urldecode($part[0]) : $part[0];
65-
$value = isset($part[1]) ? ($decode ? urldecode($part[1]) : $part[1]) : null;
65+
$value = null;
66+
67+
if (isset($part[1])) {
68+
$value = implode('=', array_slice($part, 1));
69+
70+
if ($decode) {
71+
$value = urldecode($value);
72+
}
73+
}
6674

6775
$data = HeaderUtils::combine($parts) + $data;
6876

src/Symfony/Component/HttpFoundation/Tests/CookieTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ public function testFromString()
227227

228228
$cookie = Cookie::fromString('foo', true);
229229
$this->assertEquals(Cookie::create('foo', null, 0, '/', null, false, false, false, null), $cookie);
230+
231+
$cookie = Cookie::fromString('foo_cookie=foo=1&bar=2&baz=3; expires=Tue, 22-Sep-2020 06:27:09 GMT; path=/');
232+
$this->assertEquals(Cookie::create('foo_cookie', 'foo=1&bar=2&baz=3', strtotime('Tue, 22-Sep-2020 06:27:09 GMT'), '/', null, false, false, true, null), $cookie);
230233
}
231234

232235
public function testFromStringWithHttpOnly()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy