Load cgi/escape instead of cgi/util#1366
Merged
tompng merged 1 commit intoruby:masterfrom May 13, 2025
Merged
Conversation
`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
tompng
reviewed
May 13, 2025
| require 'cgi/util' | ||
| require 'cgi/escape' | ||
| # For CGI.unescape on earlier rubies | ||
| require 'cgi/util' if RUBY_VERSION < '3.5' |
Member
There was a problem hiding this comment.
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
Merged
kou
pushed a commit
to ruby/rss
that referenced
this pull request
Oct 15, 2025
### Background A warning is currently emitted in CI when running with ruby-head (Ruby 3.5-dev). This warning occurs because `CGI::Util` will be removed in Ruby 3.5. - https://bugs.ruby-lang.org/issues/21258 - ruby/ruby#13275 ``` /home/runner/.rubies/ruby-head/lib/ruby/gems/3.5.0+2/gems/rss-0.3.2/lib/rss/rss.rb:4: warning: CGI::Util is removed from Ruby 3.5. Please use cgi/escape instead for CGI.escape and CGI.unescape features. If you are using CGI.parse, please install and use the cgi gem instead. /home/runner/work/rss/rss/tmp/test/test-dublincore.rb:2: warning: CGI library is removed from Ruby 3.5. Please use cgi/escape instead for CGI.escape and CGI.unescape features. If you need to use the full features of CGI library, Please install cgi gem. ``` https://github.com/ruby/rss/actions/runs/16902042489/job/47883073913#step:6:8 ### Details This Pull Request fixes the warning by replacing the use of `cgi/util` with `cgi/escape`. The `cgi/escape` is available since Ruby 2.3. ### Additional Information Similar fixes have been made in other libraries, such as the rdoc gem. - ruby/rdoc#1366 - ruby/rdoc#1378 - ruby/net-http@d8fd39c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cgi/utilwill warn on Ruby 3.5.cgi/escapeis available since Ruby 2.4, but to use CGI.unescape* methods on Ruby 3.4 and earlier,cgi/utilmust 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