Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentError - invalid byte sequence in UTF-8 #96

Open
tecnobrat opened this issue Mar 29, 2019 · 1 comment
Open

ArgumentError - invalid byte sequence in UTF-8 #96

tecnobrat opened this issue Mar 29, 2019 · 1 comment

Comments

@tecnobrat
Copy link

app_1      | 2019-03-29 15:55:38 - ArgumentError - invalid byte sequence in UTF-8:
app_1      |    /usr/local/bundle/gems/sinatra-param-1.6.0/lib/sinatra/param.rb:122:in `==='
app_1      |    /usr/local/bundle/gems/sinatra-param-1.6.0/lib/sinatra/param.rb:122:in `block in validate!'
app_1      |    /usr/local/bundle/gems/sinatra-param-1.6.0/lib/sinatra/param.rb:115:in `each'
app_1      |    /usr/local/bundle/gems/sinatra-param-1.6.0/lib/sinatra/param.rb:115:in `validate!'
app_1      |    /usr/local/bundle/gems/sinatra-param-1.6.0/lib/sinatra/param.rb:23:in `param'
app_1      |    /service/lib/routes/avatar.rb:19:in `block in <class:Application>'

The line in my code is:
param :email, String, blank: false

The request made to the server has a param of:
?email=%28t%B3odei%29@gmail.com

@mattt
Copy link
Owner

mattt commented Jul 26, 2019

%B3 by itself is an invalid UTF-8 byte sequence. You can verify this by entering the string into an HTML / percent-encoding decoder; the result is invalid (�).

It looks like the the rescue clause where we try to encode the invalid value to generate the exception is itself raising ArgumentError. I'll look into how we might do this more safely to handle invalid string values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants