Skip to content

Provide URI::RFC2396_PARSER for Ruby 3.3 or older #118

@yahonda

Description

@yahonda

This issue requests to provide URI::RFC2396_PARSER for Ruby 3.3 or older version because Ruby on Rails supports Ruby 3.1.0 and higher and I want to support these Ruby versions without if RUBY_VERSION clauses.

Background

Ruby on Rails runs CI against Ruby master branch and it enables RAILS_STRICT_WARNINGS=1 flag to let Rails CI fail if any warnings appeared.

Since ruby/ruby@b41d799, Rails Ci against Ruby master branch is getting failed as expected. To address this warning, I have replaced URI::DEFAULT_PARSER.escape with URI::RFC2396_PARSER.escape as suggested. It works against Ruby master branch but it raises uninitialized constant URI::RFC2396_PARSER (NameError) against Ruby 3.3.4 that bundles uri version 0.13.0

Steps to reproduce

$ irb -w

require 'uri'
URI::DEFAULT_PARSER.escape("/:controller(/:action)")
URI::RFC2396_PARSER.escape("/:controller(/:action)")

Expected behavior

Ruby 3.3.4 runs these statements without successfully warnings.

Actual behavior

It raises uninitialized constant URI::RFC2396_PARSER (NameError)

$ ruby -v
ruby 3.3.4 (2024-07-09 revision be1089c8ec) [x86_64-linux]
$ irb -w
irb(main):001> require 'uri'
=> true
irb(main):002> URI::VERSION
=> "0.13.0"
irb(main):003> URI::DEFAULT_PARSER.escape("/:controller(/:action)")
=> "/:controller(/:action)"
irb(main):004> URI::RFC2396_PARSER.escape("/:controller(/:action)")
(irb):4:in `<main>': uninitialized constant URI::RFC2396_PARSER (NameError)

URI::RFC2396_PARSER.escape("/:controller(/:action)")
   ^^^^^^^^^^^^^^^^
Did you mean?  URI::RFC2396_Parser
               URI::RFC3986_Parser
               URI::RFC3986_PARSER
	from <internal:kernel>:187:in `loop'
	from /home/yahonda/.rbenv/versions/3.3.4/lib/ruby/gems/3.3.0/gems/irb-1.14.0/exe/irb:9:in `<top (required)>'
	from /home/yahonda/.rbenv/versions/3.3.4/bin/irb:25:in `load'
	from /home/yahonda/.rbenv/versions/3.3.4/bin/irb:25:in `<main>'
irb(main):005>

Here is the result against Ruby 3.4.0dev, that works as expected.

$ ruby -v
ruby 3.4.0dev (2024-08-22T23:47:40Z master fdba458e85) [x86_64-linux]
$ irb -w
Ignoring io-console-0.7.2 because its extensions are not built. Try: gem pristine io-console --version 0.7.2
Ignoring psych-5.1.2 because its extensions are not built. Try: gem pristine psych --version 5.1.2
Ignoring cgi-0.4.1 because its extensions are not built. Try: gem pristine cgi --version 0.4.1
Ignoring date-3.3.4 because its extensions are not built. Try: gem pristine date --version 3.3.4
Ignoring io-console-0.7.2 because its extensions are not built. Try: gem pristine io-console --version 0.7.2
Ignoring json-2.7.2 because its extensions are not built. Try: gem pristine json --version 2.7.2
Ignoring prism-0.30.0 because its extensions are not built. Try: gem pristine prism --version 0.30.0
Ignoring psych-5.1.2 because its extensions are not built. Try: gem pristine psych --version 5.1.2
irb(main):001> require 'uri'
=> true
irb(main):002> URI::VERSION
=> "0.13.0"
irb(main):003> URI::DEFAULT_PARSER.escape("/:controller(/:action)")
(irb):3: warning: URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly.
=> "/:controller(/:action)"
irb(main):004> URI::RFC2396_PARSER.escape("/:controller(/:action)")
irb(main):005>

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