SECURITY: make find topic by slug adhere to SiteSetting.detailed_404 (#9898)

This commit is contained in:
Jeff Wong
2020-05-27 08:28:38 -10:00
committed by GitHub
parent 77801aa9be
commit a9d92f338e
2 changed files with 16 additions and 12 deletions

View File

@ -945,7 +945,15 @@ class TopicsController < ApplicationController
end
def redirect_to_correct_topic(topic, post_number = nil)
guardian.ensure_can_see!(topic)
begin
guardian.ensure_can_see!(topic)
rescue Discourse::InvalidAccess => ex
if !SiteSetting.detailed_404
raise Discourse::NotFound
else
raise ex
end
end
url = topic.relative_url
url << "/#{post_number}" if post_number.to_i > 0