Skip to content

Replace usage of cgi for ruby 3.5 compatibility #2131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Earlopain
Copy link

In Ruby 3.5, most of the cgi gem is removed. That includes CGI.parse, which rouge uses.

But, we can subsistute it with URI.decode_www_form. The data is returned in a slightly different format (array of arrays instead of a hash), so do some processing to get back into the expected structure.

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

In Ruby 3.5, most of the cgi gem is removed. That includes `CGI.parse`, which `rouge` uses.

But, we can subsistute it with `URI.decode_www_form`.
The data is returned in a slightly different format (array of arrays instead of a hash),
so do some processing to get back into the expected structure.

https://bugs.ruby-lang.org/issues/21258
javierjulio added a commit to javierjulio/envied that referenced this pull request Jun 6, 2025
In Ruby 3.5, most of the cgi gem is removed which includes `CGI.parse`. We can replace this with `URI.decode_www_form` but it has some slight differences. Seems any blank value now always comes back as nil rather nil or an empty string depending so this can be a breaking change.

rouge-ruby/rouge#2131
javierjulio added a commit to javierjulio/envied that referenced this pull request Jun 6, 2025
* Replace CGI with URI for Ruby 3.5 support

In Ruby 3.5, most of the cgi gem is removed which includes `CGI.parse`. We can replace this with `URI.decode_www_form` but it has some slight differences. Seems any blank value now always comes back as nil rather nil or an empty string depending so this can be a breaking change.

rouge-ruby/rouge#2131

* Update CHANGELOG.md
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.

1 participant