Project

General

Profile

Actions

Bug #13178

closed

CGI.unescape change in behavior

Added by vo.x (Vit Ondruch) about 7 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
[ruby-core:79378]

Description

CGI.unescape does not work anymore when just "cgi/util" is required.

$ ruby -v -rcgi/util -e 'CGI.unescape("foo=bar&foo=baz&page=1")'
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]

$ ruby -v -rcgi/util -e 'CGI.unescape("foo=bar&foo=baz&page=1")'
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
-e:1:in `unescape': uninitialized class variable @@accept_charset in #<Class:CGI> (NameError)
	from -e:1:in `<main>'

It works just fine if whole "cgi" is required. Not sure if this is intentional or just side effect (probably due to r55540 or r54655 ?), but it breaks existing projects, e.g. httparty test suite fails due to this change:

  1) HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER doesn't modify strings
     Failure/Error: expect(CGI.unescape(query_string)).to eq("foo=bar&foo=baz")
     NameError:
       uninitialized class variable @@accept_charset in #<Class:CGI>
     # ./spec/httparty/request_spec.rb:13:in `unescape'
     # ./spec/httparty/request_spec.rb:13:in `block (3 levels) in <top (required)>'

Also please note that httparty does not require "cqi" at all. It is required via some transitive dependencies. Presumably via ERB 1. So in case that this is intentional behavior, ERB should require s|cgi/utils|cgi| IMO.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #8354: lib/cgi/util.rb を関数としても使えるようにしたいClosedxibbar (Takeyuki FUJIOKA)05/02/2013Actions
Actions #1

Updated by nobu (Nobuyoshi Nakada) about 7 years ago

  • Related to Feature #8354: lib/cgi/util.rb を関数としても使えるようにしたい added

Updated by nobu (Nobuyoshi Nakada) about 7 years ago

  • Backport changed from 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED

It's an older bug than it.

$ ruby2.1 -rcgi -e 'CGI.accept_charset = "ISO-8859-15"; p CGI.unescape("foo").encoding'
#<Encoding:UTF-8>

There are different @@accept_charset variables.

Actions #3

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0