strip_html to ignore comments with html tags. fixes #1650

This commit is contained in:
Jason Normore
2012-06-11 10:32:12 -04:00
parent 40cc799f3d
commit 515b31158e
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ module Liquid
end
def strip_html(input)
input.to_s.gsub(/<script.*?<\/script>/, '').gsub(/<.*?>/, '')
input.to_s.gsub(/<script.*?<\/script>/, '').gsub(/<!--.*?-->/, '').gsub(/<.*?>/, '')
end
# Remove all newlines from the string
+6
View File
@@ -75,6 +75,12 @@ class FiltersTest < Test::Unit::TestCase
assert_equal "bla blub", Variable.new("var | strip_html").render(@context)
end
def test_strip_html_ignore_comments_with_html
@context['var'] = "<!-- split and some <ul> tag --><b>bla blub</a>"
assert_equal "bla blub", Variable.new("var | strip_html").render(@context)
end
def test_capitalize
@context['var'] = "blub"