Skip to content

Only load what is required from cgi for Ruby 3.5 #3247

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 4 commits into
base: version-3
Choose a base branch
from

Conversation

Earlopain
Copy link
Contributor

In Ruby 3.5, most of the cgi gem is removed. Only methods relating to escaping/unescaping are retained.

On versions before Ruby 3.5, cgi/util must be required for correct functionality.

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


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

  1. To make sure we include your contribution in the release notes, please make sure to add description entry for your changes in the "unreleased changes" section of the CHANGELOG.md file (at corresponding gem). For the description entry, please make sure it lives in one line and starts with Feature or Issue in the correct format.

  2. For generated code changes, please checkout below instructions first:
    https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md

Thank you for your contribution!

Earlopain added 2 commits May 13, 2025 10:43
This method will be removed in Ruby 3.5
In Ruby 3.5, most of the cgi gem is removed. Only methods relating to escaping/unescaping are retained.

On versions before Ruby 3.5, `cgi/util` must be required for correct functionality.

https://bugs.ruby-lang.org/issues/21258
@mullermp mullermp added the pr/blocked This PR cannot be merged or reviewed, because it is blocked for some reason. label May 13, 2025
Copy link
Contributor

@mullermp mullermp left a comment

Choose a reason for hiding this comment

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

Do we need cgi as a dependency as well? Is it being removed as a bundled gem entirely, or are you saying that parts are being removed but cgi is still bundled?

@@ -159,7 +159,7 @@ module S3
allow(Time).to receive(:now).and_return(now)
url, headers = obj.presigned_request(
:get, expires_in: 86_400, request_payer: 'peccy')
expect(CGI.parse(url)).to eq(CGI.parse(
expect(URI.decode_www_form(url)).to eq(URI.decode_www_form(
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these actually equivalent? Is there any supporting documentation for these implementations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CGI.parse: https://docs.ruby-lang.org/en/3.4/CGI.html#method-c-parse
URI.decode_www_form: https://docs.ruby-lang.org/en/3.4/URI.html#method-c-decode_www_form

It treats it as x-www-form-urlencoded, which uses the query string format of key=value&key2=value.

They return data in a slightly different format. CGI.parse returns a hash, URI.decode_www_form an array of 2-element arrays. For tests to just check against this is fine, if it were exposed to users it would need a different solution.

@mullermp
Copy link
Contributor

@Earlopain I've performed a review. Do you know for sure this change is being made? It seems a bit premature since Ruby 3.5 is not released and the cgi work is not complete.

@Earlopain
Copy link
Contributor Author

Thanks for taking a look.

Do we need cgi as a dependency as well? Is it being removed as a bundled gem entirely, or are you saying that parts are being removed but cgi is still bundled?

Things like CGI::Cookie are being removed. All the escape/unescape methods will continue to work without cgi as a dependency. So there is no need to declare it. It is being done a bit differently than the other bundled gems in the past (and rightly so, since every other gem uses these escape/unescape methods).

Do you know for sure this change is being made? It seems a bit premature since Ruby 3.5 is not released and the cgi work is not complete.

Ruby already did the work to handle this change in their own code (erb, bundler, rdoc, others I can't think about). Of course I can't say it definitly, but I am very sure. But we can wait until 3.5-preview2 (preview1 was released in april) or something along the lines, it's no rush from me.

@mullermp
Copy link
Contributor

Thanks. I think it would be prudent to wait until Ruby 3.5 preview confirms the changes. I've prepared this release with changelogs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/blocked This PR cannot be merged or reviewed, because it is blocked for some reason.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants