Skip to content

Commit

Permalink
Merge branch '3.4' into 4.0
Browse files Browse the repository at this point in the history
* 3.4:
  use brace-style regex delimiters
  Fixed typo RecursiveIterator -> RecursiveIteratorIterator
  [Cache] fix logic for fetching tag versions on TagAwareAdapter
  [FrameworkBundle] Use the correct service id for CachePoolPruneCommand in its compiler pass
  Hide short exception trace by default
  [Doctrine Bridge] fix priority for doctrine event listeners
  [Validator] make phpdoc of ObjectInitializerInterface interface more accurate
  [Validator] fixes phpdoc reference to an interface that was removed in Symfony 3.0
  • Loading branch information
fabpot committed May 7, 2018
2 parents 0144877 + fd95b06 commit 865d134
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public static function getTrustedHeaderSet()
public static function setTrustedHosts(array $hostPatterns)
{
self::$trustedHostPatterns = array_map(function ($hostPattern) {
return sprintf('#%s#i', $hostPattern);
return sprintf('{%s}i', $hostPattern);
}, $hostPatterns);
// we need to reset trusted hosts on trusted host patterns change
self::$trustedHosts = array();
Expand Down
11 changes: 9 additions & 2 deletions Tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected function tearDown()
{
// reset
Request::setTrustedProxies(array(), -1);
Request::setTrustedHosts(array());
}

public function testInitialize()
Expand Down Expand Up @@ -1924,9 +1925,15 @@ public function testTrustedHosts()

$request->headers->set('host', 'subdomain.trusted.com');
$this->assertEquals('subdomain.trusted.com', $request->getHost());
}

// reset request for following tests
Request::setTrustedHosts(array());
public function testSetTrustedHostsDoesNotBreakOnSpecialCharacters()
{
Request::setTrustedHosts(array('localhost(\.local){0,1}#,example.com', 'localhost'));

$request = Request::create('/');
$request->headers->set('host', 'localhost');
$this->assertSame('localhost', $request->getHost());
}

public function testFactory()
Expand Down

0 comments on commit 865d134

Please sign in to comment.