use brace-style regex delimiters
This commit is contained in:
parent
ffb07c6a99
commit
ae62d9bc81
@ -581,7 +581,7 @@ class Request
|
||||
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();
|
||||
|
@ -18,6 +18,11 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class RequestTest extends TestCase
|
||||
{
|
||||
protected function tearDown()
|
||||
{
|
||||
Request::setTrustedHosts(array());
|
||||
}
|
||||
|
||||
public function testInitialize()
|
||||
{
|
||||
$request = new Request();
|
||||
@ -1871,9 +1876,15 @@ class RequestTest extends TestCase
|
||||
|
||||
$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()
|
||||
|
Reference in New Issue
Block a user