Skip to content

Conversation

Earlopain
Copy link
Contributor

cgi/util will warn on Ruby 3.5. cgi/escape is available since Ruby 2.4, but to use CGI.unescape* methods on Ruby 3.4 and earlier, cgi/util must still be required.

There's only one place in rdoc that uses such a method, so only one place needs to handle earlier rubies.

https://bugs.ruby-lang.org/issues/21258

`cgi/util` will warn on Ruby 3.5. `cgi/escape` is available since Ruby 2.4,
but to use CGI.unescape* methods on Ruby 3.4 and earlier, `cgi/util` must still be required.

There's only one place in rdoc that uses such a method, so only one place needs to handle earlier rubies.

https://bugs.ruby-lang.org/issues/21258
require 'cgi/util'
require 'cgi/escape'
# For CGI.unescape on earlier rubies
require 'cgi/util' if RUBY_VERSION < '3.5'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruby -rcgi/escape -e "CGI.unescape ''"
# Ruby 3.5: OK
# Ruby 3.4: uninitialized class variable @@accept_charset in #<Class:CGI> (NameError)
ruby -rcgi/escape -rcgi/util -e "CGI.unescape ''"
# Ruby 3.4: OK

Copy link
Member

@tompng tompng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

@tompng tompng merged commit 61a2dae into ruby:master May 13, 2025
25 of 30 checks passed
@tompng tompng mentioned this pull request May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants