Skip to content

Remove CGI dependencies - #424

Merged
pboling merged 2 commits into
ruby-oauth:mainfrom
Tonguechaude:remove-CGI-dependencies
Dec 2, 2026
Merged

pboling merged 2 commits into
ruby-oauth:mainfrom
Tonguechaude:remove-CGI-dependencies

Conversation

@Tonguechaude

@Tonguechaude Tonguechaude commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ruby 4.0 no longer ships CGI.parse. This removes the library's dependency on it.

  • Adds OAuth::Helper.parse_query (and form_unescape), a drop-in replacement for CGI.parse: splits on &/;, decodes + as a space, tolerates malformed % sequences, keeps the same encoding behavior, and returns a frozen empty default.
  • Replaces every CGI.parse call in consumer.rb and the curb, em_http, net_http, rest_client and typhoeus request proxies, and drops their require "cgi".

Tests

  • parse_query specs, including a comparison against the real CGI.parse (values and encodings) when available.
  • A guard spec that fails if CGI.parse reappears in lib/.

@pboling pboling left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lib/oauth/request_proxy/action_controller_request.rb:53 still calls CGI.unescape. It should keep working on Ruby 4.0, since cgi/escape is still shipped. I can address that in a separate PR.

@pboling
pboling merged commit e63660a into ruby-oauth:main Dec 2, 2026
pboling added a commit that referenced this pull request Dec 3, 2026
Use OAuth::Helper.form_unescape, widen the CGI-independence spec to any
CGI.* call, and add changelog entries for #424 and this change.
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