spree-contrib/spree_contact_us

Exception thrown with bad data in form

dougbradbury opened this issue · 3 comments

It looks like one of the validations is causing an exception to bubble up when the data submitted is not valid UTF-8. Granted, this was spam, but I still don't want my production environment blowing up.

A ArgumentError occurred in contacts#create:

invalid byte sequence in UTF-8
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/core_ext/object/blank.rb:105:in `=~'


Request

  • Parameters: {"contact_us_contact"=>{"name"=>"Herb Kirsch", "email"=>"herb@bestmailing.com", "message"=>"Hi Robert\r\n\r\nThere\x92s a new way TO REACH THOUSANDS OF BUSINESSES just like I\x92m reaching you.\r\n\r\nReach businesses with your OVERUNS, CLOSE-OUTS, and more - within hours at NO COST!\r\n\r\nSince 1984 we\x92ve been providing marketing solutions.\r\n\r\nCall Now! 800.692.2378\r\n\r\nHerb Kirsch\r\nExecutive Vice President\r\nBest Mailing Lists, Inc.\r\n\r\n"}, "commit"=>"Send", "action"=>"create", "controller"=>"spree/contact_us/contacts"}

Backtrace:

vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/core_ext/object/blank.rb:105:in =~' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/core_ext/object/blank.rb:105:in!~'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/core_ext/object/blank.rb:105:in blank?' vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.9/lib/active_model/errors.rb:255:inblock in add_on_blank'
vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.9/lib/active_model/errors.rb:253:in each' vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.9/lib/active_model/errors.rb:253:inadd_on_blank'
vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.9/lib/active_model/validations/presence.rb:8:in validate' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:310:in_callback_before_1667'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:429:in _run__2929223480065568427__validate__623701556206372448__callbacks' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in__run_callback'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in _run_validate_callbacks' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:inrun_callbacks'
vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.9/lib/active_model/validations.rb:228:in run_validations!' vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.9/lib/active_model/validations.rb:195:invalid?'
vendor/bundle/ruby/1.9.1/bundler/gems/spree_contact_us-fcb5961f130f/app/models/spree/contact_us/contact.rb:23:in save' vendor/bundle/ruby/1.9.1/bundler/gems/spree_contact_us-fcb5961f130f/app/controllers/spree/contact_us/contacts_controller.rb:7:increate'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_controller/metal/implicit_render.rb:4:in send_action' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/abstract_controller/base.rb:167:inprocess_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_controller/metal/rendering.rb:10:in process_action' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/abstract_controller/callbacks.rb:18:inblock in process_action'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:447:in _run__1545554991106049313__process_action__3072168488830808859__callbacks' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in__run_callback'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in _run_process_action_callbacks' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:inrun_callbacks'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/abstract_controller/callbacks.rb:17:in process_action' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_controller/metal/rescue.rb:29:inprocess_action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:30:in block in process_action' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/notifications.rb:123:inblock in instrument'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/notifications/instrumenter.rb:20:in instrument' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/notifications.rb:123:ininstrument'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_controller/metal/instrumentation.rb:29:in process_action' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_controller/metal/params_wrapper.rb:207:inprocess_action'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/railties/controller_runtime.rb:18:in process_action' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/abstract_controller/base.rb:121:inprocess'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/abstract_controller/rendering.rb:45:in process' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_controller/metal.rb:203:indispatch'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_controller/metal/rack_delegation.rb:14:in dispatch' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_controller/metal.rb:246:inblock in action'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:73:in call' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:73:indispatch'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:36:in call' vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:inblock in call'
vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in each' vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:incall'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:601:in call' vendor/bundle/ruby/1.9.1/gems/spree_core-1.2.0/lib/spree/core/middleware/redirect_legacy_product_url.rb:13:incall'
vendor/bundle/ruby/1.9.1/gems/spree_core-1.2.0/lib/spree/core/middleware/seo_assist.rb:27:in call' vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/engine.rb:479:incall'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in method_missing' vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:68:inblock in call'
vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:in each' vendor/bundle/ruby/1.9.1/gems/journey-1.0.4/lib/journey/router.rb:56:incall'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/routing/route_set.rb:601:in call' vendor/bundle/ruby/1.9.1/gems/exception_notification-2.6.1/lib/exception_notifier.rb:34:incall'
vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/manager.rb:35:in block in call' vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/manager.rb:34:incatch'
vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/manager.rb:34:in call' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/best_standards_support.rb:17:incall'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/etag.rb:23:in call' vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/conditionalget.rb:35:incall'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/head.rb:14:in call' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/params_parser.rb:21:incall'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/flash.rb:242:in call' vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:incontext'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in call' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/cookies.rb:341:incall'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/query_cache.rb:64:in call' vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:incall'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/callbacks.rb:28:in block in call' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in_run__2071896375922411250__call__623701556206372448__callbacks'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in __run_callback' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in_run_call_callbacks'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:in run_callbacks' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/callbacks.rb:27:incall'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/remote_ip.rb:31:in call' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/debug_exceptions.rb:16:incall'
vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/show_exceptions.rb:56:in call' vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/rack/logger.rb:32:incall_app'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/rack/logger.rb:16:in block in call' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/tagged_logging.rb:22:intagged'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/rack/logger.rb:16:in call' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/request_id.rb:22:incall'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in call' vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:incall'
vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/cache/strategy/local_cache.rb:72:in call' vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:incall'
vendor/bundle/ruby/1.9.1/gems/rack-rewrite-1.2.1/lib/rack/rewrite.rb:20:in call' vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/static.rb:62:incall'
vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in forward' vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:inpass'
vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in invalidate' vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:incall!'
vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in call' vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/engine.rb:479:incall'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:223:in call' vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/content_length.rb:14:incall'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/rack/log_tailer.rb:17:in call' vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/connection.rb:81:inblock in pre_process'
vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/connection.rb:79:in catch' vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/connection.rb:79:inpre_process'
vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/connection.rb:54:in process' vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/connection.rb:39:inreceive_data'
vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in run_machine' vendor/bundle/ruby/1.9.1/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:inrun'
vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/backends/base.rb:63:in start' vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/server.rb:159:instart'
vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in run' vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:265:instart'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands/server.rb:70:in start' vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:55:inblock in <top (required)>'
vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:50:in tap' vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:50:in<top (required)>'
script/rails:6:in require' script/rails:6:in

'

Thanks for reporting this, and I'll look into fixing it once I get a chance. Or I'd accept a pull request fixing the issue if you are able to handle it first.

Could you also let me know which version of Ruby your running? There were changes to encoding in Ruby 1.9 that may be relevant.

This was on heroku's cedar stack
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

I'm knee deep in my 1.3.0 upgrade, but I'll send you a request if I have the time.

I'm unable to reproduce this error. I also don't believe there is anything that should be done within this extension. It appears to be a bug in Rails handling of non utf-8 characters in url parsing. I've seen several other posts after doing some googling of others running into the same issue. So I would open an issue with Rails to deal with this at the root of the problem.