Actions
Bug #20686
openURI::HTTPS can build URI with blank, invalid host
Description
In Ruby 3.4.0+, calling URI::HTTPS.build(host: "")
does not raise URI::InvalidComponentError
as expected. Instead, it returns #<URI::HTTPS https://>
I think this was introduced in this PR.
Steps to Reproduce¶
1. Environment:¶
- Ruby Version: 3.4.0+
2. Steps:¶
-
Open an IRB session.
-
Run:
URI::HTTPS.build(host: "")
3. Expected Behavior:¶
-
URI::InvalidComponentError
should be raised due to the invalid emptyhost
component.
4. Actual Behavior:¶
- Returns
#<URI::HTTPS https://>
without raising an error.
Ruby 3.1.4:¶
irb(main):008:0> RUBY_VERSION
=> "3.1.4"
irb(main):009:0> URI::HTTPS.build(host:"")
/home/vscode/.rbenv/versions/3.1.4/lib/ruby/3.1.0/uri/generic.rb:601:in `check_host': bad component(expected host component): (URI::InvalidComponentError)
Ruby 3.4.0:¶
irb(…):015> RUBY_VERSION
=> "3.4.0"
irb(...):016> URI::HTTPS.build(host:"")
=> #<URI::HTTPS https://>
Actions
Like0
Like0Like0Like0Like0