31Aug/1012
warning: regexp match /…/n against to UTF-8 string error when using Cucumber
Ever since updating my environment to Rails 3.0.0 / RSpec 2.0.0.beta.20 / Cucumber 0.8.5 / Capybara 0.3.9 / Autotest 4.3.2, I've been getting the following error when Cucumber runs my features:
GEM_PATH/rack-1.2.1/lib/rack/utils.rb:16: warning: regexp match /.../n against to UTF-8 string |
It seems that Rack is having a problem whenever UTF-8 strings are sent in the params. Thankfully, these guys found a solution.
For a more verbose description, check out that page. Here's the quick and dirty:
Install the escape_utils gem by including this in your Gemfile:
gem "escape_utils" |
Run bundle install to install the gem. Now, create a new file: RAILS_ROOT/config/initializers/escape_utils.rb with the following content:
module Rack module Utils def escape(s) EscapeUtils.escape_url(s) end end end |
And that should do it!
December 13th, 2010 - 12:25
Thanks! This works.
March 22nd, 2011 - 07:47
If you are using Rails 3 and escape_utils be warned that version 0.2.0 has a buffer over-read issue that will cause two characters to be truncated from your post parameters randomly under load. Once we upgraded to 0.2.3 the problem went away.
July 11th, 2011 - 23:17
That sounds like an issue that would take many hours to solve. Thank you for passing the knowledge on.
June 28th, 2011 - 13:40
Perfect! What an annoying little bug.
August 7th, 2011 - 16:57
Thanks! Worked great for me!
August 15th, 2011 - 12:12
Works for me too with Rails 3.0.9. Thanks.
February 16th, 2012 - 12:12
Thanks Man!!!
Works For me!
March 23rd, 2012 - 16:10
Thank you! Worked greate!
April 23rd, 2012 - 14:55
Thank you. : )
August 22nd, 2012 - 07:46
Great fix, thank you. Point of interest, the ‘these guys’ link resulted in an nginx 500 error for me today. OH THE IRONY.
August 22nd, 2012 - 11:49
No worries–glad it helped!
April 10th, 2013 - 21:44
Just watch what you put in 3.2 and on production…. basically i have a unicorn error log full of “cache error: uninitialized constant Rack::Utils::EscapeUtils” and a line going to : home/blah/config/initializers/escape_utils.rb:7:in `escape’ in case google should cache this.