NoMethodError when deleting cookies from Rails with Rack 1.3 #291

Closed
emassip opened this Issue Dec 19, 2011 · 8 comments

Comments

Projects
None yet
2 participants

emassip commented Dec 19, 2011

I don't know if this can be considered as a Rails issue or a Rack one, but as it worked in previous versions of Rack, that's where it'll be reported.

Right now with Rack 1.3 we can't use Rails's cookies[:my_cookie_key] anymore:

NoMethodError in AccountController#logout

private method `gsub' called for :autologin:Symbol
RAILS_ROOT: /usr/share/redmine

Application Trace | Framework Trace | Full Trace
/usr/lib/ruby/vendor_ruby/rack/backports/uri/common.rb:24:in `encode_www_form_component'
/usr/lib/ruby/vendor_ruby/rack/utils.rb:23:in `escape'
/usr/lib/ruby/vendor_ruby/rack/utils.rb:201:in `set_cookie_header!'
/usr/lib/ruby/vendor_ruby/rack/utils.rb:238:in `delete_cookie_header!'
/usr/lib/ruby/vendor_ruby/rack/response.rb:63:in `delete_cookie'
/usr/lib/ruby/vendor_ruby/action_controller/cookies.rb:94:in `delete'

Rack 1.1.1 Utils#escape:

def escape(s)
  s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
    '%'+$1.unpack('H2'*bytesize($1)).join('%').upcase
  }.tr(' ', '+')
end

Rack 1.3.1 Utils#escape:

def escape(s)
  URI.encode_www_form_component(s)
end

Please note that the to_s has been crushed.

Using cookies['my_cookie_key'] works but is not the Rails way.

I don't understand why I can't find any related issues reported, I must be missing something??

emassip commented Dec 19, 2011

Crushed by f0beb34.

Owner

raggi commented Dec 19, 2011

@tenderlove AAAARRRROOONNNNNNNN!!!!!!!!!!! fueling my fire baby, you know the argument <3

Owner

raggi commented Dec 21, 2011

@emassip this appears to be working for me, what version of ruby are you on?

emassip commented Dec 22, 2011

@raggi this issue comes from http://www.redmine.org/issues/9118.

Ruby 1.8.7, Rails 2.3.11.

Not experienced by myself because I don't use Rack 1.3 yet; I reported it after digging around Rack call stack code after I saw that the to_s has been removed.

Owner

raggi commented Dec 27, 2011

This is actually fixed in common_18.rb in 48d302c. That's only in master so far.

emassip closed this Jan 24, 2012

emassip commented Jan 24, 2012

Rack 1.4 has been released so it should be fixed.

raggi reopened this Jan 25, 2012

Owner

raggi commented Jan 25, 2012

Rails 2.x uses rack 1.3. I'll back port this when i get to the 1.3.x patch level release (as soon as I have some time).

Owner

raggi commented Jan 14, 2013

I failed to backport this. Does anyone still need that? Re-open if so.

raggi closed this Jan 14, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment