Skip to content

Commit

Permalink
Merge pull request lokka#213 from morygonzalez/fix-admin-xss
Browse files Browse the repository at this point in the history
Fix potentially XSS on admin/comments#index
  • Loading branch information
morygonzalez committed Nov 8, 2015
2 parents cb348ba + 86cd415 commit 4684f8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion public/admin/comments/index.haml
Expand Up @@ -12,7 +12,7 @@
- status = case comment.status; when Comment::APPROVED; t('comment_approved'); when Comment::MODERATED; t('comment_moderated'); when Comment::SPAM; t('comment_spam'); end
%td= status
%td.body= link_to truncate(strip_tags(comment.body)), url(comment.link)
%td= comment.name
%td= h(comment.name)
%td= l(comment.created_at, :format => :long)
%td= link_to t('edit'), url("/admin/comments/#{comment.id}/edit"), :class => 'button'
%td= link_to t('delete'), url("/admin/comments/#{comment.id}"), :class => 'button', :confirm => t('are_you_sure'), :method => :delete
Expand Down
13 changes: 13 additions & 0 deletions spec/integration/admin/comments_spec.rb
Expand Up @@ -89,4 +89,17 @@
it_behaves_like 'a not found page'
end
end

context "When <xmp> tag is used in comment author's name" do
before do
@comment.update(name: "<xmp>")
end

context "GET /admin/comments" do
it "should escape html tag" do
get "/admin/comments"
last_response.body.should match(/&lt;xmp&gt;/)
end
end
end
end

0 comments on commit 4684f8b

Please sign in to comment.