mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Liquid strip_html strips out the content of <script> tags. [#173 state:resolved]
This commit is contained in:
committed by
James MacAulay
parent
fce8bcb1e7
commit
d87500bfe3
@@ -48,7 +48,7 @@ module Liquid
|
||||
end
|
||||
|
||||
def strip_html(input)
|
||||
input.to_s.gsub(/<.*?>/, '')
|
||||
input.to_s.gsub(/<script.*?<\/script>/, '').gsub(/<.*?>/, '')
|
||||
end
|
||||
|
||||
# Remove all newlines from the string
|
||||
|
||||
@@ -57,6 +57,7 @@ class StandardFiltersTest < Test::Unit::TestCase
|
||||
def test_strip_html
|
||||
assert_equal 'test', @filters.strip_html("<div>test</div>")
|
||||
assert_equal 'test', @filters.strip_html("<div id='test'>test</div>")
|
||||
assert_equal '', @filters.strip_html("<script type='text/javascript'>document.write('some stuff');</script>")
|
||||
assert_equal '', @filters.strip_html(nil)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user