A platform for community discussion. Free, open, simple.
FIX: tags_descriptions exposes PM tag metadata when PM tags are hidden (#39817)
Samec9ec6fc7437
diff --git a/app/serializers/concerns/topic_tags_mixin.rb b/app/serializers/concerns/topic_tags_mixin.rbindex e96f143db9c..60ec824e107 100644--- a/app/serializers/concerns/topic_tags_mixin.rb+++ b/app/serializers/concerns/topic_tags_mixin.rb@@ -12,6 +12,10 @@ module TopicTagsMixinscope.can_see_tags?(topic)end+ def include_tags_descriptions?+ include_tags?+ end+def tagsall_tags.map { |tag| { id: tag.id, name: localized_tag_name(tag), slug: tag.slug_for_url } }enddiff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rbindex 66b28f2afd0..4c2ea1283bf 100644--- a/spec/requests/topics_controller_spec.rb+++ b/spec/requests/topics_controller_spec.rb@@ -2892,6 +2892,22 @@ RSpec.describe TopicsController doexpect(response.status).to eq(200)end+ it "does not expose private message tag descriptions when the viewer cannot see tags" do+ SiteSetting.tagging_enabled = true+ SiteSetting.pm_tags_allowed_for_groups = Group::AUTO_GROUPS[:admins].to_s+ pm_post = Fabricate(:private_message_post, user: admin, recipient: user)+ pm_topic = pm_post.topic+ pm_tag = Fabricate(:tag, name: "secret-pm-tag", description: "secret PM tag description")+ pm_topic.tags << pm_tag++ sign_in(user)+ get "/t/#{pm_topic.slug}/#{pm_topic.id}.json"++ expect(response.status).to eq(200)+ expect(response.parsed_body).not_to have_key("tags")+ expect(response.parsed_body).not_to have_key("tags_descriptions")+ end+it "shows a blank-slug topic without redirecting" dotopic.update_columns(title: "", slug: nil)topic.reload