diff options
author | Thibaut Girka <thib@sitedethib.com> | 2020-01-04 22:54:06 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2020-01-04 23:04:42 +0100 |
commit | 01eaeab56df4da4c697b1096f40a400cc9e2b8e8 (patch) | |
tree | 6288ee106b4615cacd98362f9fd268317a9cdeff /app/middleware | |
parent | 22daf24600d8e99e4569740ee5836d25c70c1e8b (diff) | |
parent | 2ecc7802caf4d272191a7fd582fc97996f750827 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - `app/controllers/application_controller.rb`: Conflict due to theming system. - `app/controllers/oauth/authorizations_controller.rb`: Conflict due to theming system.
Diffstat (limited to 'app/middleware')
-rw-r--r-- | app/middleware/handle_bad_encoding_middleware.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/middleware/handle_bad_encoding_middleware.rb b/app/middleware/handle_bad_encoding_middleware.rb new file mode 100644 index 000000000..6fce84b15 --- /dev/null +++ b/app/middleware/handle_bad_encoding_middleware.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +# See: https://jamescrisp.org/2018/05/28/fixing-invalid-query-parameters-invalid-encoding-in-a-rails-app/ + +class HandleBadEncodingMiddleware + def initialize(app) + @app = app + end + + def call(env) + begin + Rack::Utils.parse_nested_query(env['QUERY_STRING'].to_s) + rescue Rack::Utils::InvalidParameterError + env['QUERY_STRING'] = '' + end + + @app.call(env) + end +end |