mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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:
@@ -177,6 +177,7 @@ module HTML #:nodoc:
|
||||
case text
|
||||
when "\\" then
|
||||
value << text
|
||||
break if scanner.eos?
|
||||
value << scanner.getch
|
||||
when delim
|
||||
break
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -257,6 +257,10 @@ class SanitizerTest < ActionController::TestCase
|
||||
assert_sanitized %{<a href=\"http://www.domain.com?var1=1&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
|
||||
|
||||
Reference in New Issue
Block a user