Skip to content

Require cgi/escape instead of cgi#1825

Merged
xavdid-stripe merged 1 commit intostripe:masterfrom
jeremyevans:cgi-escape
Mar 19, 2026
Merged

Require cgi/escape instead of cgi#1825
xavdid-stripe merged 1 commit intostripe:masterfrom
jeremyevans:cgi-escape

Conversation

@jeremyevans
Copy link
Copy Markdown
Contributor

stripe does not have a dependency on cgi. If you have stripe in your Gemfile, but not cgi, there is a verbose mode warning when requiring stripe on Ruby 4.0. Example file:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'stripe'
  gem 'logger' # Missing gem dependency on logger, different issue
end

require "stripe"

Running in verbose mode:

$ ruby -v t.rb
ruby 4.0.2 (2026-03-17 revision d3da9fec82) +PRISM [x86_64-linux]
/home/jeremy/.local/share/mise/installs/ruby/4.0.2/lib/ruby/gems/4.0.0/gems/stripe-18.4.2/lib/stripe.rb:5: warning: CGI library is removed from Ruby 4.0. Please use cgi/escape instead for CGI.escape and CGI.unescape features.
If you need to use the full features of CGI library, Please install cgi gem.

The only cases in that are using a CGI method other than CGI.escape is in a couple tests using CGI.parse, so add cgi to the Gemfile and require cgi in those two test files. Switch the cgi require in lib to cgi/escape. This avoids the warning, and will avoid breakage in Ruby 4.1.

stripe does not have a dependency on cgi. If you have stripe in your
Gemfile, but not cgi, there is a verbose mode warning when requiring
stripe on Ruby 4.0. Example file:

```
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'stripe'
  gem 'logger' # Missing gem dependency on logger, different issue
end

require "stripe"
```

Running in verbose mode:

```
$ ruby -v t.rb
ruby 4.0.2 (2026-03-17 revision d3da9fec82) +PRISM [x86_64-linux]
/home/jeremy/.local/share/mise/installs/ruby/4.0.2/lib/ruby/gems/4.0.0/gems/stripe-18.4.2/lib/stripe.rb:5: warning: CGI library is removed from Ruby 4.0. Please use cgi/escape instead for CGI.escape and CGI.unescape features.
If you need to use the full features of CGI library, Please install cgi gem.
```

The only cases in that are using a CGI method other than CGI.escape is
in a couple tests using CGI.parse, so add cgi to the Gemfile and require
cgi in those two test files. Switch the cgi require in lib to
cgi/escape.  This avoids the warning, and will avoid breakage in
Ruby 4.1.
@jeremyevans jeremyevans requested a review from a team as a code owner March 19, 2026 03:34
@jeremyevans jeremyevans requested review from xavdid-stripe and removed request for a team March 19, 2026 03:34
Copy link
Copy Markdown
Contributor

@xavdid-stripe xavdid-stripe left a comment

Choose a reason for hiding this comment

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

awesome, thank you!

@xavdid-stripe xavdid-stripe merged commit f69d848 into stripe:master Mar 19, 2026
11 checks passed
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