Skip to content

Commit

Permalink
Ensure full match. Fixes #1590.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Feb 10, 2020
1 parent 3d7a634 commit 784dcd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rack/request.rb
Expand Up @@ -598,7 +598,7 @@ def split_header(value)
value ? value.strip.split(/[,\s]+/) : []
end

AUTHORITY = /
AUTHORITY = /^
# The host:
(?<host>
# An IPv6 address:
Expand All @@ -612,7 +612,7 @@ def split_header(value)
)
# The optional port:
(:(?<port>\d+))?
/x
$/x

private_constant :AUTHORITY

Expand Down
5 changes: 5 additions & 0 deletions test/spec_request.rb
Expand Up @@ -116,6 +116,11 @@ class RackRequestTest < Minitest::Spec
req.host.must_equal "www2.example.org"
req.hostname.must_equal "www2.example.org"

req = make_request \
Rack::MockRequest.env_for("/", "HTTP_HOST" => "123foo.example.com")
req.host.must_equal "123foo.example.com"
req.hostname.must_equal "123foo.example.com"

req = make_request \
Rack::MockRequest.env_for("/", "SERVER_NAME" => "example.org", "SERVER_PORT" => "9292")
req.host.must_equal "example.org"
Expand Down

0 comments on commit 784dcd2

Please sign in to comment.