diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2020-01-02 17:14:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-02 17:14:58 +0100 |
commit | 09d54d1f626163fcc6e282544dfc9939fd3cdfd3 (patch) | |
tree | 4e19c261bb8cdc3d64228a0299072a286d409fa3 /spec/middleware | |
parent | 9edab7afafd6f6db9338ada83a84b2ef14f397a9 (diff) |
Fix uncaught query param encoding errors (#12741)
Diffstat (limited to 'spec/middleware')
-rw-r--r-- | spec/middleware/handle_bad_encoding_middleware_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/middleware/handle_bad_encoding_middleware_spec.rb b/spec/middleware/handle_bad_encoding_middleware_spec.rb new file mode 100644 index 000000000..8c0d24f18 --- /dev/null +++ b/spec/middleware/handle_bad_encoding_middleware_spec.rb @@ -0,0 +1,21 @@ +require 'rails_helper' + +RSpec.describe HandleBadEncodingMiddleware do + let(:app) { double() } + let(:middleware) { HandleBadEncodingMiddleware.new(app) } + + it "request with query string is unchanged" do + expect(app).to receive(:call).with("PATH" => "/some/path", "QUERY_STRING" => "name=fred") + middleware.call("PATH" => "/some/path", "QUERY_STRING" => "name=fred") + end + + it "request with no query string is unchanged" do + expect(app).to receive(:call).with("PATH" => "/some/path") + middleware.call("PATH" => "/some/path") + end + + it "request with invalid encoding in query string drops query string" do + expect(app).to receive(:call).with("QUERY_STRING" => "", "PATH" => "/some/path") + middleware.call("QUERY_STRING" => "q=%2Fsearch%2Fall%Forder%3Ddescending%26page%3D5%26sort%3Dcreated_at", "PATH" => "/some/path") + end +end |