forked from e621ng/e621ng
[Comments] Prevent hidden comment leak in API
This commit is contained in:
parent
2c40167c39
commit
b47e837ee5
@ -54,6 +54,7 @@ class CommentsController < ApplicationController
|
||||
|
||||
def show
|
||||
@comment = Comment.find(params[:id])
|
||||
check_visible(@comment)
|
||||
@comment_votes = CommentVote.for_comments_and_user([@comment.id], CurrentUser.id)
|
||||
respond_with(@comment)
|
||||
end
|
||||
@ -105,6 +106,12 @@ private
|
||||
end
|
||||
end
|
||||
|
||||
def check_visible(comment)
|
||||
if !comment.visible_to?(CurrentUser.user)
|
||||
raise User::PrivilegeError
|
||||
end
|
||||
end
|
||||
|
||||
def comment_params(context)
|
||||
permitted_params = %i[body post_id]
|
||||
permitted_params += %i[do_not_bump_post] if context == :create
|
||||
|
Loading…
Reference in New Issue
Block a user