Skip to content

Commit ad72938

Browse files
Merge branch '2.8' into 3.4
* 2.8: [HttpKernel] Fixed invalid REMOTE_ADDR in inline subrequest when configuring trusted proxy with subnet [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 c34def7 + 9aa26b3 commit ad72938

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
@@ -266,7 +266,7 @@ public function isHttpOnly()
266266
*/
267267
public function isCleared()
268268
{
269-
return $this->expire < time();
269+
return 0 !== $this->expire && $this->expire < time();
270270
}
271271

272272
/**

Request.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,10 @@ public function getMethod()
13531353
if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) {
13541354
$this->method = strtoupper($method);
13551355
} elseif (self::$httpMethodParameterOverride) {
1356-
$this->method = strtoupper($this->request->get('_method', $this->query->get('_method', 'POST')));
1356+
$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
1357+
if (\is_string($method)) {
1358+
$this->method = strtoupper($method);
1359+
}
13571360
}
13581361
}
13591362
}

Tests/CookieTest.php

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

159159
$this->assertTrue($cookie->isCleared(), '->isCleared() returns true if the cookie has expired');
160+
161+
$cookie = new Cookie('foo', 'bar');
162+
163+
$this->assertFalse($cookie->isCleared());
164+
165+
$cookie = new Cookie('foo', 'bar', 0);
166+
167+
$this->assertFalse($cookie->isCleared());
168+
169+
$cookie = new Cookie('foo', 'bar', -1);
170+
171+
$this->assertFalse($cookie->isCleared());
160172
}
161173

162174
public function testToString()

Tests/RequestTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,11 @@ public function testGetSetMethod()
848848
$request->setMethod('POST');
849849
$request->headers->set('X-HTTP-METHOD-OVERRIDE', 'delete');
850850
$this->assertEquals('DELETE', $request->getMethod(), '->getMethod() returns the method from X-HTTP-Method-Override if defined and POST');
851+
852+
$request = new Request();
853+
$request->setMethod('POST');
854+
$request->query->set('_method', array('delete', 'patch'));
855+
$this->assertSame('POST', $request->getMethod(), '->getMethod() returns the request method if invalid type is defined in query');
851856
}
852857

853858
/**

0 commit comments

Comments
 (0)