Skip to content

Commit

Permalink
Strip_tags never ending attribute should not raise a TypeError [rails…
Browse files Browse the repository at this point in the history
…#4870 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
nono authored and josevalim committed Jun 28, 2010
1 parent dd8b741 commit 2002e58
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Expand Up @@ -177,6 +177,7 @@ def parse(parent, line, pos, content, strict=true)
case text
when "\\" then
value << text
break if scanner.eos?
value << scanner.getch
when delim
break
Expand Down
Expand Up @@ -96,6 +96,7 @@ def consume_quoted_regions
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
Expand Down
4 changes: 4 additions & 0 deletions actionpack/test/template/html-scanner/sanitizer_test.rb
Expand Up @@ -257,6 +257,10 @@ def test_should_not_mangle_urls_with_ampersand
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
Expand Down

0 comments on commit 2002e58

Please sign in to comment.