Skip to content

URI generated by URI::Generic.new doesn't conform to RFC 2732 for IPv6 addresses #224

@zunda

Description

@zunda

URI with a literal IPv6 address needs to have a pair of brackets, [ and ], according to RFC 2732. However, the uri library doesn't add the brackets:

$ irb

⢀⡴⠊⢉⡟⢿  IRB v1.18.0 - Ruby 4.0.3
⣎⣀⣴⡋⡟⣻  Type "help" for commands, "help <cmd>" for details
⣟⣼⣱⣽⣟⣾  ~/c/src/local/rk26-code-party

> require 'uri'
> s = URI::Generic.new('https', nil, '::1', 443, nil, '/', nil, nil, nil).to_s
=> "https://::1:443/"

and makes it impossible to be parsed:

> URI.parse(s)
.../4.0.3/lib/ruby/4.0.0/uri/rfc3986_parser.rb:130:in 'URI::RFC3986_Parser#split': bad URI (is not URI?): "https://::1:443/" (URI::InvalidURIError)

Might it be necessary to add a pair of brackets when the host part is a literal IPv6 address?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions