Skip to content

A platform for community discussion. Free, open, simple.

DEV: Ignore invalid tag parameter in TagsController (#28557)

Penar Musarajee3b175373f7
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index 10b105acc2c..fbf0953d991 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -585,6 +585,6 @@ class TagsController < ::ApplicationController
end
def tag_params
- Array(params[:tags]).concat(Array(@additional_tags))
+ Array(params[:tags]).map(&:to_s).concat(Array(@additional_tags))
end
end
diff --git a/spec/requests/tags_controller_spec.rb b/spec/requests/tags_controller_spec.rb
index 5b247625b12..a962655dff3 100644
--- a/spec/requests/tags_controller_spec.rb
+++ b/spec/requests/tags_controller_spec.rb
@@ -518,6 +518,11 @@ RSpec.describe TagsController do
expect(topic_ids).to_not include(topic_in_subcategory_without_tag.id)
end
end
+
+ it "should ignore invalid tag parameter" do
+ get "/tag/test.json?tags[0]=nada"
+ expect(response.status).to eq(200)
+ end
end
describe "#info" do