Skip to content

Commit

Permalink
Merge branch '4.0' into 4.1
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nicolas-grekas committed Aug 1, 2018
2 parents ce6e382 + e0e05e9 commit da12951
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function isHttpOnly()
*/
public function isCleared()
{
return $this->expire < time();
return 0 !== $this->expire && $this->expire < time();
}

/**
Expand Down
5 changes: 4 additions & 1 deletion Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,10 @@ public function getMethod()
if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) {
$this->method = strtoupper($method);
} elseif (self::$httpMethodParameterOverride) {
$this->method = strtoupper($this->request->get('_method', $this->query->get('_method', 'POST')));
$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
if (\is_string($method)) {
$this->method = strtoupper($method);
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions Tests/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ public function testCookieIsCleared()
$cookie = new Cookie('foo', 'bar', time() - 20);

$this->assertTrue($cookie->isCleared(), '->isCleared() returns true if the cookie has expired');

$cookie = new Cookie('foo', 'bar');

$this->assertFalse($cookie->isCleared());

$cookie = new Cookie('foo', 'bar', 0);

$this->assertFalse($cookie->isCleared());

$cookie = new Cookie('foo', 'bar', -1);

$this->assertFalse($cookie->isCleared());
}

public function testToString()
Expand Down
5 changes: 5 additions & 0 deletions Tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,11 @@ public function testGetSetMethod()
$request->setMethod('POST');
$request->headers->set('X-HTTP-METHOD-OVERRIDE', 'delete');
$this->assertEquals('DELETE', $request->getMethod(), '->getMethod() returns the method from X-HTTP-Method-Override if defined and POST');

$request = new Request();
$request->setMethod('POST');
$request->query->set('_method', array('delete', 'patch'));
$this->assertSame('POST', $request->getMethod(), '->getMethod() returns the request method if invalid type is defined in query');
}

/**
Expand Down

0 comments on commit da12951

Please sign in to comment.