Commit 8383b52e919f32187208aa4db758a5c1549b7769
Committed by
Antonio Terceiro
1 parent
0f455456
Exists in
master
and in
28 other branches
Filtering xss attack in comment field name
(ActionItem1371)
Showing
2 changed files
with
9 additions
and
1 deletions
Show diff stats
app/models/comment.rb
test/unit/comment_test.rb
... | ... | @@ -179,4 +179,12 @@ class CommentTest < Test::Unit::TestCase |
179 | 179 | assert comment.url[:view] |
180 | 180 | end |
181 | 181 | |
182 | + should 'not fill fields with javascript' do | |
183 | + owner = create_user('testuser').person | |
184 | + article = owner.articles.create!(:name => 'test', :body => '...') | |
185 | + javascript = "<script>alert('XSS')</script>" | |
186 | + comment = article.comments.create!(:article => article, :name => javascript, :title => javascript, :body => javascript, :email => 'cracker@test.org') | |
187 | + assert_no_match(/<script>/, comment.name) | |
188 | + end | |
189 | + | |
182 | 190 | end | ... | ... |