Skip to content

Conversation

Earlopain
Copy link

In Ruby 3.5 most of the cgi gem will be removed. Only the various escape/unescape methods will be retained by default.

But: cgi/escape only exists since Ruby 2.3. So I fall back to cgi/util on earlier versions.

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

@postmodern
Copy link
Member

The linked upstream issue is still open and they appear to still be discussing what to do with cgi. Testing under ruby-3.5.0-preview1, one can still require cgi, cgi/escape, and cgi/util, and call CGI.escapeHTML. This doesn't appear to be an issue, yet. Feel free to re-open when cgi is removed from stdlib.

@postmodern postmodern closed this May 15, 2025
@postmodern
Copy link
Member

Hmm, it looks like hsbt's PR was merged into Ruby master, so cgi will be soft-removed in 3.5.0-preview2, with a placeholder cgi.rb file left behind recommending using cgi/escape instead. At that point I'll probably use this code from the PR instead:

      begin
        require 'cgi/escape'
      rescue LoadError
        require 'cgi/util'
      end

@postmodern postmodern reopened this May 15, 2025
@postmodern postmodern self-assigned this May 15, 2025
In Ruby 3.5 most of the `cgi` gem will be removed. Only the various
escape/unescape methods will be retained by default.

But: `cgi/escape` only exists since Ruby 2.3. So I fall back to `cgi/util` on earlier versions.

https://bugs.ruby-lang.org/issues/21258
@Earlopain
Copy link
Author

Sure, I changed it and left a comment for which ruby version it applies

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