Invalid byte sequence in UTF-8 when requesting a page

I get an "invalid byte sequence in UTF-8" on page requests (permalinks), and I have no idea why I cannot play it, but I have many exceptions like:

A ArgumentError occurred in products#index:

 invalid byte sequence in UTF-8
 activesupport (3.0.4) lib/active_support/core_ext/object/blank.rb:68:in `=~'

-------------------------------
Request:
-------------------------------

 * URL       : http://www.mysite.com/category/category-name-\x8E~ice
 * Parameters: {"page"=>1, "controller"=>"products", "action"=>"index", "category"=>"category-name-\x8E~ice"}

The line at the end should not be there ("- \ x8E ~ ice"). Any idea why this shows up or what I can do to debug / reproduce it?

thank

+3
source share
4 answers

we created rails middleware that filters out all the weird encodings that cannot be processed in our application.

, , , , , Cp1252/Windows-1252. ruby ​​1.9 utge-8 regexps, .

iconv, , , mac, . , , ...

+13

UTF8Cleaner, @phoet @pithyless. Railtie, Gemfile " ".

https://github.com/singlebrook/utf8-cleaner

+7

Like @phoet, I also used Rails middleware to solve similar encoding problems.

Tested on Ruby 1.9.3 (no Iconv):

https://gist.github.com/3639014

0
source

If you use apache (and mod_rails), you can prevent these invalid URL requests from uninstalling the Rails application completely by running this answer:

https://stackoverflow.com/questions/13512727/how-can-i-configure-apache-to-respond-400-when-request-contains-an-invalid-byte/13527812#13527812

0
source

All Articles