Skip to content

Commit 8079a6b

Browse files
Merge branch '3.2' into 3.3
* 3.2: [DI] Handle root namespace in service definitions Use rawurlencode() to transform the Cookie into a string [Security] Fix authentication.failure event not dispatched on AccountStatusException
2 parents 3a4435e + 3fdd972 commit 8079a6b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Cookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct($name, $value, $expires = null, $path = null, $domai
6262
$this->rawValue = $value;
6363
} else {
6464
$this->value = $value;
65-
$this->rawValue = urlencode($value);
65+
$this->rawValue = rawurlencode($value);
6666
}
6767
$this->name = $name;
6868
$this->path = empty($path) ? '/' : $path;

Tests/CookieTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@
1616

1717
class CookieTest extends TestCase
1818
{
19+
public function testToString()
20+
{
21+
$cookie = new Cookie('foo', 'bar', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true);
22+
$this->assertEquals('foo=bar; expires=Fri, 20 May 2011 15:25:52 GMT; domain=.myfoodomain.com; path=/; secure; httponly', (string) $cookie, '->__toString() returns string representation of the cookie');
23+
24+
$cookie = new Cookie('foo', 'bar with white spaces', strtotime('Fri, 20-May-2011 15:25:52 GMT'), '/', '.myfoodomain.com', true);
25+
$this->assertEquals('foo=bar%20with%20white%20spaces; expires=Fri, 20 May 2011 15:25:52 GMT; domain=.myfoodomain.com; path=/; secure; httponly', (string) $cookie, '->__toString() encodes the value of the cookie according to RFC 3986 (white space = %20)');
26+
27+
$cookie = new Cookie('foo', null, 1, '/admin/', '.myfoodomain.com');
28+
$this->assertEquals('foo=; expires=Thu, 01 Jan 1970 00:00:01 GMT; domain=.myfoodomain.com; path=/admin/; httponly', (string) $cookie, '->__toString() returns string representation of a cleared cookie if value is NULL');
29+
30+
$cookie = new Cookie('foo', 'bar', 0, '/', '');
31+
$this->assertEquals('foo=bar; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; httponly', (string) $cookie);
32+
}
33+
1934
/**
2035
* @dataProvider getTestsForToFromString
2136
*/

0 commit comments

Comments
 (0)