Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

Commit bfe0328

Browse files
gtdNZKoz
authored andcommitted
Make sure strip_tags removes tags which start with a non-printable character
Signed-off-by: Michael Koziarski <[email protected]>
1 parent 3719bd3 commit bfe0328

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

actionpack/lib/action_controller/vendor/html-scanner/html/node.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def parse(parent, line, pos, content, strict=true)
162162
end
163163

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

168168
unless closing

actionpack/test/controller/html-scanner/sanitizer_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def test_strip_tags
1919
assert_equal "This has a here.", sanitizer.sanitize("This has a <!-- comment --> here.")
2020
assert_equal "This has a here.", sanitizer.sanitize("This has a <![CDATA[<section>]]> here.")
2121
assert_equal "This has an unclosed ", sanitizer.sanitize("This has an unclosed <![CDATA[<section>]] here...")
22+
assert_equal "non printable char is a tag", sanitizer.sanitize("<\x07a href='/hello'>non printable char is a tag</a>")
2223
[nil, '', ' '].each { |blank| assert_equal blank, sanitizer.sanitize(blank) }
2324
end
2425

0 commit comments

Comments
 (0)