diff options
author | Jonne Haß <me@jhass.eu> | 2014-05-16 18:10:06 +0400 |
---|---|---|
committer | Jonne Haß <me@jhass.eu> | 2014-05-16 18:10:06 +0400 |
commit | 9e2c914a1bba4ac11854980f94414cb52e8ea8c4 (patch) | |
tree | 12d8eaea4f237a77e5f50c143409bb2d888a227f /app/helpers/report_helper.rb | |
parent | 01381ddf25b8cd7eb7720049b06ad23f6985e5f1 (diff) | |
parent | 8170ef8363e8db5427a8d24a0f47bf2142e9875a (diff) |
Merge pull request #4961 from Zauberstuhl/report_feature_issue_4959
Do not try to render post/comment report which does not exist
Diffstat (limited to 'app/helpers/report_helper.rb')
-rw-r--r-- | app/helpers/report_helper.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/helpers/report_helper.rb b/app/helpers/report_helper.rb index 370981314..10509ccfd 100644 --- a/app/helpers/report_helper.rb +++ b/app/helpers/report_helper.rb @@ -4,13 +4,14 @@ module ReportHelper def report_content(id, type) - raw case type - when 'post' - t('report.post_label', title: link_to(post_page_title(Post.find_by_id(id)), post_path(id))) - when 'comment' - # comment_message is not html_safe. To prevent - # cross-site-scripting we have to escape html - t('report.comment_label', data: h(comment_message(Comment.find_by_id(id)))) + if type == 'post' && !(post = Post.find_by_id(id)).nil? + raw t('report.post_label', title: link_to(post_page_title(post), post_path(id))) + elsif type == 'comment' && !(comment = Comment.find_by_id(id)).nil? + # comment_message is not html_safe. To prevent + # cross-site-scripting we have to escape html + raw t('report.comment_label', data: h(comment_message(comment))) + else + raw t('report.not_found') end end end |