8000 Include untrusted host in the exception message · webmozart/symfony@fd2f633 · GitHub
[go: up one dir, main page]

Skip to content

Commit fd2f633

Browse files
committed
Include untrusted host in the exception message
1 parent 4cfbdf1 commit fd2f633

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ public function getHost()
11011101
// as the host can come from the user (HTTP_HOST and depending on the configuration, SERVER_NAME too can come from the user)
11021102
// check that it does not contain forbidden characters (see RFC 952 and RFC 2181)
11031103
if ($host && !preg_match('/^\[?(?:[a-zA-Z0-9-:\]_]+\.?)+$/', $host)) {
1104-
throw new \UnexpectedValueException('Invalid Host');
1104+
throw new \UnexpectedValueException('Invalid Host "'.$host.'"');
11051105
}
11061106

11071107
if (count(self::$trustedHostPatterns) > 0) {
@@ -1119,7 +1119,7 @@ public function getHost()
11191119
}
11201120
}
11211121

1122-
throw new \UnexpectedValueException('Untrusted Host');
1122+
throw new \UnexpectedValueException('Untrusted Host "'.$host.'"');
11231123
}
11241124

11251125
return $host;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ public function testTrustedHosts()
15201520
$request->getHost();
15211521
$this->fail('Request::getHost() should throw an exception when host is not trusted.');
15221522
} catch (\UnexpectedValueException $e) {
1523-
$this->assertEquals('Untrusted Host', $e->getMessage());
1523+
$this->assertEquals('Untrusted Host "evil.com"', $e->getMessage());
15241524
}
15251525

15261526
// trusted hosts

0 commit comments

Comments
 (0)
0