fix: replace CGI.parse, removed in Ruby 4.0, with URI.decode_www_form - #793
Open
gagalago wants to merge 1 commit into
Open
fix: replace CGI.parse, removed in Ruby 4.0, with URI.decode_www_form#793gagalago wants to merge 1 commit into
gagalago wants to merge 1 commit into
Conversation
8 tasks
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.
Changes
test_par_authorization_url_builds_correctlyfails on Ruby 4.0 becauseCGI.parseno longer exists:Ruby 4.0 trimmed the
cgilibrary down to its escaping helpers.CGI.escape,CGI.unescape,CGI.escapeHTMLandCGI.unescapeHTMLall remain, butCGI.parseis gone, andrequire "cgi"does not bring it back.This replaces the single call with
URI.decode_www_form(...).to_h, which is the standard-library replacement and needs no new require — the test already usesURI.parseon the line above.URI.decode_www_formreturns[[key, value], ...], soto_hgives values directly and the two.firstcalls are no longer needed. Both parameters in this test are single-valued, so nothing is lost.No library code is affected. The only
CGIusage inlib/isCGI.escapeinAuthenticationEndpoints#to_query, which still exists in Ruby 4.0. This is a test-only fix.References
Found while testing an application against
auth0on Ruby 4.0.6.auth0.gemspecdeclaresrequired_ruby_version = ">= 3.3.0"with no upper bound, so Ruby 4 is in scope for the gem, and this is currently the only thing standing between the suite and a clean run there.cgireduced to the escape helpersURI.decode_www_formTesting
No new test — this repairs an existing one, which is the check.
Full suite, same command on both interpreters:
552 runs, 0 failures, 0 errors552 runs, 0 failures, 0 errors552 runs, 0 failures, **1 error**552 runs, 0 failures, 0 errorsI also confirmed the replacement is equivalent for this test's input rather than assuming it.
request_uriisurn:ietf:params:oauth:request_uri:the.request.uri, whose colons are percent-encoded byCGI.escapeinto_query;URI.decode_www_formdecodes them back identically, so the assertion still compares real decoded values and has not become vacuous.Checklist