Project

General

Profile

Actions

Bug #20686

open

URI::HTTPS can build URI with blank, invalid host

Added by ronricardo (Roniece Ricardo) 12 days ago. Updated 12 days ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:118894]

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 empty host 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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0