You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using utf8-cleaner for quite a while. To be honest I don't quite know if it has had any effect in the application - I put it 'just in case' given that it seems a well maintained gem, and I was experiencing requests with problematic encodings.
Theoretically if I use utf8-cleaner, no request URL encoding should ever cause a 500, right?
Well, I am able to consistently reproduce this in my app:
utf8-cleaner’s purpose is to remove invalid UTF-8 characters from the
environment. I don’t think this error is due to invalid UTF-8, per se.
It’s caused by having characters from multiple character sets in the same
string.
If you’re using Rails, I’d suggest adding a rescue_from in your
ApplicationController that rescues this particular exception (which might
involve inspecting the message as well as the class) and returns a 400
error instead of a 500. This is exceptionally bad input, and it’s the
client’s responsibility to fix it, not the servers.*
The same could probably be said of most exceptions that utf8-handler
prevents, but oh well….
Hi there!
I've been using utf8-cleaner for quite a while. To be honest I don't quite know if it has had any effect in the application - I put it 'just in case' given that it seems a well maintained gem, and I was experiencing requests with problematic encodings.
Theoretically if I use utf8-cleaner, no request URL encoding should ever cause a 500, right?
Well, I am able to consistently reproduce this in my app:
(anonimized domain/route/params)
Internaly the error is:
ActionView::Template::Error: incompatible character encodings: UTF-8 and ASCII-8BIT
Unfortunately I cannot reproduce this on my machine; I am able to consistently reproduce it in production though.
Setup 1 (localhost, not reproducible)
Plain Rails server:
Setup 2 (localhost, not reproducible)
Rails server behind local instance of nginx.
Setup 3 (production, reproducible)
Cloudflare -> AWS ELB -> nginx -> Rails server
My point is that maybe Cloudflare/ELB are doing something funny.
Let me know if I can do anything to help debugging the issue.
Cheers - Victor
The text was updated successfully, but these errors were encountered: