Strip_tags never ending attribute should not raise a TypeError [#4870 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Bruno Michel
2010-06-26 19:00:57 +02:00
committed by José Valim
parent dd8b7417a9
commit 2002e5877e
3 changed files with 6 additions and 0 deletions

View File

@@ -177,6 +177,7 @@ module HTML #:nodoc:
case text
when "\\" then
value << text
break if scanner.eos?
value << scanner.getch
when delim
break

View File

@@ -96,6 +96,7 @@ module HTML #:nodoc:
while match = @scanner.scan_until(/[\\#{delim}]/)
text << match
break if @scanner.matched == delim
break if @scanner.eos?
text << @scanner.getch # skip the escaped character
end
end

View File

@@ -257,6 +257,10 @@ class SanitizerTest < ActionController::TestCase
assert_sanitized %{<a href=\"http://www.domain.com?var1=1&amp;var2=2\">my link</a>}
end
def test_should_sanitize_neverending_attribute
assert_sanitized "<span class=\"\\", "<span class=\"\\\">"
end
protected
def assert_sanitized(input, expected = nil)
@sanitizer ||= HTML::WhiteListSanitizer.new