Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Duplicate of #3144: active_support/message_verifier.rb — undefined method `^' for "a":String

#3150

Ruby Version: ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin10]
Rails Version: 2.3.4

It appears there's a small bug in the way message_verifier builds result in the private secure_compare method under Ruby 1.9.

undefined method `^' for "a":String

/opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/message_verifier.rb:46:in `block in secure_compare'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/message_verifier.rb:45:in `each'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/message_verifier.rb:45:in `secure_compare'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/message_verifier.rb:28:in `verify'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:156:in `unmarshal'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:145:in `load_session'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/session/abstract_store.rb:62:in `block in load!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/session/abstract_store.rb:70:in `stale_session_check!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/session/abstract_store.rb:61:in `load!'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/session/abstract_store.rb:28:in `[]'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/request_forgery_protection.rb:102:in `form_authenticity_token'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/request_forgery_protection.rb:92:in `verified_request?'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/request_forgery_protection.rb:79:in `verify_authenticity_token'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:178:in `evaluate_method'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/callbacks.rb:166:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/filters.rb:225:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/filters.rb:629:in `run_before_filters'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/filters.rb:615:in `call_filters'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/filters.rb:610:in `perform_action_with_filters'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `block in perform_action_with_benchmark'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `block in ms'
/opt/local/lib/ruby1.9/1.9.1/benchmark.rb:309:in `realtime'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/core_ext/benchmark.rb:17:in `ms'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/benchmarking.rb:68:in `perform_action_with_benchmark'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/rescue.rb:160:in `perform_action_with_rescue'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/flash.rb:146:in `perform_action_with_flash'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/base.rb:532:in `process'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/filters.rb:606:in `process_with_filters'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/haml-2.2.3/lib/sass/plugin/rails.rb:19:in `process'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/chriseppstein-compass-0.8.14/lib/compass/app_integration/rails/action_controller.rb:7:in `process_with_compass'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/base.rb:391:in `process'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/base.rb:386:in `call'
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:437:in `call'

In Ruby 1.8 calling str[fixnum] will convert the character at fixnum in to an Integer ordinal. In Ruby 1.9 this same method call returns the actual character.

I've patched the message_verifier method using is_a?(String), which seems a bit dirty but does make the test pass in 1.9. I could have used RUBY_VERSION but couldn't decide which would be more obvious to someone scanning the code.

J~

Reported by James Conroy-Finn · September 5th, 2009 @ 02:20 AM

State: duplicate
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. James Conroy-Finn
    James Conroy-Finn
    • Title changed from active_support/message_verifier.rb — undefined method `^' for "a":String to Duplicate of #3144: active_support/message_verifier.rb — undefined method `^' for "a":String

    September 5th, 2009 @ 02:25 AM

  2. Matt Jones
    Matt Jones
    • State changed from new to duplicate

    Closing as duplicate.

    September 5th, 2009 @ 05:27 AM