Skip to content

Commit da12951

Browse files
Merge branch '4.0' into 4.1
* 4.0: [HttpKernel] Fixed invalid REMOTE_ADDR in inline subrequest when configuring trusted proxy with subnet [FrameworkBundle] fixed guard event names for transitions [DI] Improve class named servics error message [HttpFoundation] fixed using _method parameter with invalid type [Intl] Replace svn with git in the icu data update script [HttpFoundation] Fix Cookie::isCleared
2 parents ce6e382 + e0e05e9 commit da12951

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

Cookie.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function isHttpOnly()
252252
*/
253253
public function isCleared()
254254
{
255-
return $this->expire < time();
255+
return 0 !== $this->expire && $this->expire < time();
256256
}
257257

258258
/**

Request.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,10 @@ public function getMethod()
12181218
if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) {
12191219
$this->method = strtoupper($method);
12201220
} elseif (self::$httpMethodParameterOverride) {
1221-
$this->method = strtoupper($this->request->get('_method', $this->query->get('_method', 'POST')));
1221+
$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
1222+
if (\is_string($method)) {
1223+
$this->method = strtoupper($method);
1224+
}
12221225
}
12231226
}
12241227
}

Tests/CookieTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ public function testCookieIsCleared()
154154
$cookie = new Cookie('foo', 'bar', time() - 20);
155155

156156
$this->assertTrue($cookie->isCleared(), '->isCleared() returns true if the cookie has expired');
157+
158+
$cookie = new Cookie('foo', 'bar');
159+
160+
$this->assertFalse($cookie->isCleared());
161+
162+
$cookie = new Cookie('foo', 'bar', 0);
163+
164+
$this->assertFalse($cookie->isCleared());
165+
166+
$cookie = new Cookie('foo', 'bar', -1);
167+
168+
$this->assertFalse($cookie->isCleared());
157169
}
158170

159171
public function testToString()

Tests/RequestTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,11 @@ public function testGetSetMethod()
854854
$request->setMethod('POST');
855855
$request->headers->set('X-HTTP-METHOD-OVERRIDE', 'delete');
856856
$this->assertEquals('DELETE', $request->getMethod(), '->getMethod() returns the method from X-HTTP-Method-Override if defined and POST');
857+
858+
$request = new Request();
859+
$request->setMethod('POST');
860+
$request->query->set('_method', array('delete', 'patch'));
861+
$this->assertSame('POST', $request->getMethod(), '->getMethod() returns the request method if invalid type is defined in query');
857862
}
858863

859864
/**

0 commit comments

Comments
 (0)