Skip to content

Commit 46aff51

Browse files
Merge branch '3.2'
* 3.2: [Security] Fix test [Validator] phpize default option values test for the Validator component to be present [Serializer] Fix MaxDepth annotation exceptions [DependencyInjection] Fix on-invalid attribute type in xsd [FrameworkBundle] Fix PHP form templates on translatable attributes [VarDumper] Fix dumping by-ref variadics [Validator] add Indonesian translation fixed CS [config] Fix issue when key removed and left value only [HttpFoundation] Fix cookie to string conversion for raw cookies Fix misresolved parameters in debug:config on 3.2 [Console] fixed BC issue with static closures [TwigBundle] Config is now a hard dependency [FrameworkBundle] framework.annotations default should be true only if doctrine/annotations is installed [Security] AbstractVoter method supportsAttribute gives false positive if attribute is zero (0)
2 parents 9e77f5c + cdce6a6 commit 46aff51

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Cookie.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,20 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom
9191
*/
9292
public function __toString()
9393
{
94-
$str = urlencode($this->getName()).'=';
94+
$str = ($this->isRaw() ? $this->getName() : urlencode($this->getName())).'=';
9595

9696
if ('' === (string) $this->getValue()) {
9797
$str .= 'deleted; expires='.gmdate('D, d-M-Y H:i:s T', time() - 31536001).'; max-age=-31536001';
9898
} else {
99-
$str .= urlencode($this->getValue());
99+
$str .= $this->isRaw() ? $this->getValue() : urlencode($this->getValue());
100100

101101
if ($this->getExpiresTime() !== 0) {
102102
$str .= '; expires='.gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime()).'; max-age='.$this->getMaxAge();
103103
}
104104
}
105105

106-
if ($this->path) {
107-
$str .= '; path='.$this->path;
106+
if ($this->getPath()) {
107+
$str .= '; path='.$this->getPath();
108108
}
109109

110110
if ($this->getDomain()) {
@@ -139,7 +139,7 @@ public function getName()
139139
/**
140140
* Gets the value of the cookie.
141141
*
142-
* @return string
142+
* @return string|null
143143
*/
144144
public function getValue()
145145
{
@@ -149,7 +149,7 @@ public function getValue()
149149
/**
150150
* Gets the domain that the cookie is available to.
151151
*
152-
* @return string
152+
* @return string|null
153153
*/
154154
public function getDomain()
155155
{

Tests/CookieTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,13 @@ public function testToString()
158158

159159
public function testRawCookie()
160160
{
161-
$cookie = new Cookie('foo', 'bar', 3600, '/', '.myfoodomain.com', false, true);
161+
$cookie = new Cookie('foo', 'b a r', 0, '/', null, false, false);
162162
$this->assertFalse($cookie->isRaw());
163+
$this->assertEquals('foo=b+a+r; path=/', (string) $cookie);
163164

164-
$cookie = new Cookie('foo', 'bar', 3600, '/', '.myfoodomain.com', false, true, true);
165+
$cookie = new Cookie('foo', 'b+a+r', 0, '/', null, false, false, true);
165166
$this->assertTrue($cookie->isRaw());
167+
$this->assertEquals('foo=b+a+r; path=/', (string) $cookie);
166168
}
167169

168170
public function testGetMaxAge()

0 commit comments

Comments
 (0)