Skip to content

Commit e0e05e9

Browse files
Merge branch '3.4' into 4.0
* 3.4: [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 8fa1b5d + ad72938 commit e0e05e9

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
@@ -1221,7 +1221,10 @@ public function getMethod()
12211221
if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) {
12221222
$this->method = strtoupper($method);
12231223
} elseif (self::$httpMethodParameterOverride) {
1224-
$this->method = strtoupper($this->request->get('_method', $this->query->get('_method', 'POST')));
1224+
$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
1225+
if (\is_string($method)) {
1226+
$this->method = strtoupper($method);
1227+
}
12251228
}
12261229
}
12271230
}

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
@@ -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)