The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

19 lines
419 B

  1. # frozen_string_literal: true
  2. # See: https://jamescrisp.org/2018/05/28/fixing-invalid-query-parameters-invalid-encoding-in-a-rails-app/
  3. class HandleBadEncodingMiddleware
  4. def initialize(app)
  5. @app = app
  6. end
  7. def call(env)
  8. begin
  9. Rack::Utils.parse_nested_query(env['QUERY_STRING'].to_s)
  10. rescue Rack::Utils::InvalidParameterError
  11. env['QUERY_STRING'] = ''
  12. end
  13. @app.call(env)
  14. end
  15. end