Skip to content
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

Unexpected behavior of CGI#unescape when required via aws-sdk #1493

Closed
bankair opened this issue Apr 25, 2017 · 6 comments
Closed

Unexpected behavior of CGI#unescape when required via aws-sdk #1493

bankair opened this issue Apr 25, 2017 · 6 comments

Comments

@bankair
Copy link

bankair commented Apr 25, 2017

Hi Folks,

I'm currently using aws-sdk 2.9.11, and it seems to have a bad side effect on the behavior of CGI#unescape.

Ruby version: mri 2.4.1

Gemfile:

source 'https://rubygems.org'
gem 'aws-sdk', '~> 2'

Test file:

require 'aws-sdk'
# The next line should print 'foo bar'
puts CGI.unescape('foo%20bar')

What I expected: an output line showing 'foo bar'.

What I got:
the following exception:

test.rb:3:in `unescape': uninitialized class variable @@accept_charset in #<Class:CGI> (NameError)
Did you mean?  @@accept_charset
	from test.rb:3:in `<main>'

An easy workaround is adding an explicit require "CGI" before (or after) the aws sdk require:

require 'CGI'
require 'aws-sdk'
# The next line prints 'foo bar'
puts CGI.unescape('foo%20bar')
@awood45
Copy link
Member

awood45 commented Apr 25, 2017

This definitely looks like a side effect of #1487 - and the best possible workaround seems to be what you've already discovered, to require the rest of the cgi library as needed.

However the exception is very unhelpful...considering if we should return the old require pattern.

@bankair
Copy link
Author

bankair commented Apr 26, 2017

Yep, I agree on the usefulness of the exception 😄

@cjyclaire
Copy link
Contributor

Adding info.

Looks like this is another problem with Ruby 2.4, I can reproduce the same error there. For Ruby 2.3, it works fine though. Definitely an issue that we will follow up with.

@awood45
Copy link
Member

awood45 commented Apr 27, 2017

Okay, given that this seems to be a Ruby 2.4 change in cgi, it's probably easiest to just patch that now be reverting to the full CGI import now, and figure out what they changed later.

@awood45 awood45 added bug and removed bug labels Apr 27, 2017
@awood45
Copy link
Member

awood45 commented Apr 27, 2017

On second thought, the bug label is inappropriate given that the weirdness seems to center on Ruby proper (consider opening an issue with them), but I'll change the import strategy regardless.

@awood45
Copy link
Member

awood45 commented Apr 27, 2017

I've pushed a fix to this that will go out with the next release.

@awood45 awood45 closed this as completed Apr 27, 2017
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

No branches or pull requests

3 participants