diff options
author | Jeremy Evans <[email protected]> | 2019-08-26 22:22:00 -0700 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2019-10-24 19:47:20 +0900 |
commit | c28d50a753615dff9bd721f608846d4ef541feb1 (patch) | |
tree | 913020f5314b994cf6f550e0ac1d5714507df030 /lib/webrick/httprequest.rb | |
parent | 37c266aa57fc2c6798a7b6002867643ef0424fa1 (diff) |
[ruby/webrick] Support literal IPv6 addresses in X-Forwarded-Host
https://github.com/ruby/webrick/commit/6b6990ec81
Diffstat (limited to 'lib/webrick/httprequest.rb')
-rw-r--r-- | lib/webrick/httprequest.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/webrick/httprequest.rb b/lib/webrick/httprequest.rb index e402099a30..87dc879175 100644 --- a/lib/webrick/httprequest.rb +++ b/lib/webrick/httprequest.rb @@ -611,7 +611,12 @@ module WEBrick end if host_port = self["x-forwarded-host"] host_port = host_port.split(",", 2).first - @forwarded_host, tmp = host_port.split(":", 2) + if host_port =~ /\A(\[[0-9a-fA-F:]+\])(?::(\d+))?\z/ + @forwarded_host = $1 + tmp = $2 + else + @forwarded_host, tmp = host_port.split(":", 2) + end @forwarded_port = (tmp || (@forwarded_proto == "https" ? 443 : 80)).to_i end if addrs = self["x-forwarded-for"] |