-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
Problem
Rack::Request#host
returns unexpected host when the domain starts with a number.
Rack v2.1.2 returns host correctly.
gem 'rack', '2.1.2'
require 'rack'
p Rack::Request.new({'HTTP_HOST' => '123foo.example.com'}).host
# => "123foo.example.com"
But Rack v2.2.0 (and v2.2.1) returns a part of the host unexpectedly.
gem 'rack', '2.2.0'
require 'rack'
p Rack::Request.new({'HTTP_HOST' => '123foo.example.com'}).host
# => "123"
I guess the cause is the following pull request. #1561
Lines 601 to 615 in 838ce3a
AUTHORITY = / | |
# The host: | |
(?<host> | |
# An IPv6 address: | |
(\[(?<ip6>.*)\]) | |
| | |
# An IPv4 address: | |
(?<ip4>[\d\.]+) | |
| | |
# A hostname: | |
(?<name>[a-zA-Z0-9\.\-]+) | |
) | |
# The optional port: | |
(:(?<port>\d+))? | |
/x |
The
AUTHORITY
regexp looks too loose. 123
matches as an ip4
, but it is not an ip4.Metadata
Metadata
Assignees
Labels
No labels