Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow undescore character in Uri host #524

Open
wants to merge 2 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Message/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct($uri)
}
// @codeCoverageIgnoreEnd

if ($parts === false || (isset($parts['scheme']) && !\preg_match('#^[a-z]+$#i', $parts['scheme'])) || (isset($parts['host']) && \preg_match('#[\s_%+]#', $parts['host']))) {
if ($parts === false || (isset($parts['scheme']) && !\preg_match('#^[a-z]+$#i', $parts['scheme'])) || (isset($parts['host']) && \preg_match('#[\s%+]#', $parts['host']))) {
throw new \InvalidArgumentException('Invalid URI given');
}

Expand Down Expand Up @@ -173,7 +173,7 @@ public function withHost($host)
return $this;
}

if (\preg_match('#[\s_%+]#', $host) || ($host !== '' && \parse_url('http://' . $host, \PHP_URL_HOST) !== $host)) {
if (\preg_match('#[\s%+]#', $host) || ($host !== '' && \parse_url('http://' . $host, \PHP_URL_HOST) !== $host)) {
WyriHaximus marked this conversation as resolved.
Show resolved Hide resolved
throw new \InvalidArgumentException('Invalid URI host given');
}

Expand Down
5 changes: 4 additions & 1 deletion tests/Message/UriTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ public static function provideValidUris()
),
array(
'http://user%20name:pass%20word@localhost/path%20name?query%20name#frag%20ment'
)
),
array(
'http://docker_container/'
),
);
}

Expand Down