mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 00:00:46 +08:00
SECURITY: Update to exclude tag topic filter (#20006)
Ignores tags specified in exclude_tag topics param that a user does not have access to. Co-authored-by: Blake Erickson <o.blakeerickson@gmail.com>
This commit is contained in:
@ -409,6 +409,9 @@ RSpec.describe TopicQuery do
|
||||
fab!(:tagged_topic3) { Fabricate(:topic, tags: [tag, other_tag]) }
|
||||
fab!(:tagged_topic4) { Fabricate(:topic, tags: [uppercase_tag]) }
|
||||
fab!(:no_tags_topic) { Fabricate(:topic) }
|
||||
fab!(:tag_group) do
|
||||
Fabricate(:tag_group, permissions: { "staff" => 1 }, tag_names: [other_tag.name])
|
||||
end
|
||||
let(:synonym) { Fabricate(:tag, target_tag: tag, name: "synonym") }
|
||||
|
||||
it "excludes a tag if desired" do
|
||||
@ -416,6 +419,11 @@ RSpec.describe TopicQuery do
|
||||
expect(topics.any? { |t| t.tags.include?(tag) }).to eq(false)
|
||||
end
|
||||
|
||||
it "does not exclude a tagged topic without permission" do
|
||||
topics = TopicQuery.new(user, exclude_tag: other_tag.name).list_latest.topics
|
||||
expect(topics.map(&:id)).to include(tagged_topic2.id)
|
||||
end
|
||||
|
||||
it "returns topics with the tag when filtered to it" do
|
||||
expect(TopicQuery.new(moderator, tags: tag.name).list_latest.topics).to contain_exactly(
|
||||
tagged_topic1,
|
||||
|
Reference in New Issue
Block a user