Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ae62d9b

Browse filesBrowse files
committed
use brace-style regex delimiters
1 parent ffb07c6 commit ae62d9b
Copy full SHA for ae62d9b

File tree

2 files changed

+14
-3
lines changed
Filter options

2 files changed

+14
-3
lines changed

‎src/Symfony/Component/HttpFoundation/Request.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Request.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ public static function getTrustedProxies()
581581
public static function setTrustedHosts(array $hostPatterns)
582582
{
583583
self::$trustedHostPatterns = array_map(function ($hostPattern) {
584-
return sprintf('#%s#i', $hostPattern);
584+
return sprintf('{%s}i', $hostPattern);
585585
}, $hostPatterns);
586586
// we need to reset trusted hosts on trusted host patterns change
587587
self::$trustedHosts = array();

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818

1919
class RequestTest extends TestCase
2020
{
21+
protected function tearDown()
22+
{
23+
Request::setTrustedHosts(array());
24+
}
25+
2126
public function testInitialize()
2227
{
2328
$request = new Request();
@@ -1871,9 +1876,15 @@ public function testTrustedHosts()
18711876

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

1875-
// reset request for following tests
1876-
Request::setTrustedHosts(array());
1881+
public function testSetTrustedHostsDoesNotBreakOnSpecialCharacters()
1882+
{
1883+
Request::setTrustedHosts(array('localhost(\.local){0,1}#,example.com', 'localhost'));
1884+
1885+
$request = Request::create('/');
1886+
$request->headers->set('host', 'localhost');
1887+
$this->assertSame('localhost', $request->getHost());
18771888
}
18781889

18791890
public function testFactory()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.