Skip to content

Commit

Permalink
[HttpFoundation] Allow curly braces in trusted host patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrodzicki committed Apr 28, 2015
1 parent 7f24883 commit 6038b75
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -553,7 +553,7 @@ public static function getTrustedProxies()
public static function setTrustedHosts(array $hostPatterns)
{
self::$trustedHostPatterns = array_map(function ($hostPattern) {
return sprintf('{%s}i', str_replace('}', '\\}', $hostPattern));
return sprintf('#%s#i', $hostPattern);
}, $hostPatterns);
// we need to reset trusted hosts on trusted host patterns change
self::$trustedHosts = array();
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Expand Up @@ -1601,7 +1601,7 @@ public function testTrustedHosts()
$this->assertEquals('evil.com', $request->getHost());

// add a trusted domain and all its subdomains
Request::setTrustedHosts(array('.*\.?trusted.com$'));
Request::setTrustedHosts(array('^([a-z]{9}\.)?trusted\.com$'));

// untrusted host
$request->headers->set('host', 'evil.com');
Expand Down

0 comments on commit 6038b75

Please sign in to comment.