sinatra-param
sinatra-param copied to clipboard
ArgumentError - invalid byte sequence in UTF-8
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%[email protected]
%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.