Skip to content

Commit 6038b75

Browse files
committed
[HttpFoundation] Allow curly braces in trusted host patterns
1 parent 7f24883 commit 6038b75

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ public static function getTrustedProxies()
553553
public static function setTrustedHosts(array $hostPatterns)
554554
{
555555
self::$trustedHostPatterns = array_map(function ($hostPattern) {
556-
return sprintf('{%s}i', str_replace('}', '\\}', $hostPattern));
556+
return sprintf('#%s#i', $hostPattern);
557557
}, $hostPatterns);
558558
// we need to reset trusted hosts on trusted host patterns change
559559
self::$trustedHosts = array();

src/Symfony/Component/HttpFoundation/Tests/RequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ public function testTrustedHosts()
16011601
$this->assertEquals('evil.com', $request->getHost());
16021602

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

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

0 commit comments

Comments
 (0)