Skip to content

Commit

Permalink
Make sure strip_tags removes tags which start with a non-printable ch…
Browse files Browse the repository at this point in the history
…aracter

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information
gtd authored and NZKoz committed Nov 27, 2009
1 parent a60779f commit 785281a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Expand Up @@ -162,7 +162,7 @@ def parse(parent, line, pos, content, strict=true)
end

closing = ( scanner.scan(/\//) ? :close : nil )
return Text.new(parent, line, pos, content) unless name = scanner.scan(/[\w:-]+/)
return Text.new(parent, line, pos, content) unless name = scanner.scan(/[-:\w\x00-\x09\x0b-\x0c\x0e-\x1f]+/)
name.downcase!

unless closing
Expand Down
1 change: 1 addition & 0 deletions actionpack/test/controller/html-scanner/sanitizer_test.rb
Expand Up @@ -19,6 +19,7 @@ def test_strip_tags
assert_equal "This has a here.", sanitizer.sanitize("This has a <!-- comment --> here.")
assert_equal "This has a here.", sanitizer.sanitize("This has a <![CDATA[<section>]]> here.")
assert_equal "This has an unclosed ", sanitizer.sanitize("This has an unclosed <![CDATA[<section>]] here...")
assert_equal "non printable char is a tag", sanitizer.sanitize("<\x07a href='/hello'>non printable char is a tag</a>")
[nil, '', ' '].each { |blank| assert_equal blank, sanitizer.sanitize(blank) }
end

Expand Down

0 comments on commit 785281a

Please sign in to comment.