Created
December 29, 2025 19:09
-
-
Save danlo/137212aaa8e4eb9ec411e77cbcb76aa3 to your computer and use it in GitHub Desktop.
Documentation about moving from Ruby 3 and less to Ruby 4 and removing CGI from our site.
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
| # Warning: LLM created | |
| Before: | |
| CGI.escape | |
| After: | |
| URI.encode_www_form_component (most often this one) | |
| URI.encode_www_form | |
| # Ruby 3.2+ and Ruby 4: Use URI::DEFAULT_PARSER.escape for custom escaping, but prefer encode_www_form_component for URLs | |
| Before: | |
| CGI.unescape | |
| After: | |
| NOT USED | |
| # Ruby 3.2+ and Ruby 4: URI.decode_www_form_component | |
| Before: | |
| CGI.escapeHTML | |
| After: | |
| ERB::Util.html_escape | |
| # Ruby 4: ERB::Escape.html_escape(text) | |
| Before: | |
| CGI.unescapeHTML | |
| After: | |
| NOT USED | |
| # Ruby 3.2+ and Ruby 4: ERB::Escape.unescape_html (requires 'erb/escape') | |
| # Or: CGI.unescape_html (removed in Ruby 4) | |
| Before: | |
| CGI.escapeURIComponent | |
| After: | |
| URI::DEFAULT_PARSER.escape_uri_component or Addressable::URI.encode_component | |
| # Ruby 4: URI::DEFAULT_PARSER.escape_uri_component or Addressable::URI.encode_component | |
| Before: | |
| CGI.unescapeURIComponent | |
| After: | |
| URI::DEFAULT_PARSER.unescape_uri_component or Addressable::URI.unencode_component | |
| # Ruby 4: URI::DEFAULT_PARSER.unescape_uri_component or Addressable::URI.unencode_component | |
| Before: | |
| CGI.escapeElement | |
| After: | |
| ERB::Escape.html_escape_element (requires 'erb/escape') | |
| # Ruby 4: ERB::Escape.html_escape_element (requires 'erb/escape') | |
| Before: | |
| CGI.unescapeElement | |
| After: | |
| ERB::Escape.unescape_html_element (requires 'erb/escape') | |
| # Ruby 4: ERB::Escape.unescape_html_element (requires 'erb/escape') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment