mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-02 16:45:12 -07: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
|
end
|
||||||
|
|
||||||
def strip_html(input)
|
def strip_html(input)
|
||||||
input.to_s.gsub(/<.*?>/, '')
|
input.to_s.gsub(/<script.*?<\/script>/, '').gsub(/<.*?>/, '')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Remove all newlines from the string
|
# Remove all newlines from the string
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class StandardFiltersTest < Test::Unit::TestCase
|
|||||||
def test_strip_html
|
def test_strip_html
|
||||||
assert_equal 'test', @filters.strip_html("<div>test</div>")
|
assert_equal 'test', @filters.strip_html("<div>test</div>")
|
||||||
assert_equal 'test', @filters.strip_html("<div id='test'>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)
|
assert_equal '', @filters.strip_html(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user