Skip to content

Commit

Permalink
strip_html to ignore comments with html tags. fixes Shopify#1650
Browse files Browse the repository at this point in the history
  • Loading branch information
jnormore committed Jun 11, 2012
1 parent 40cc799 commit 515b311
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/liquid/standardfilters.rb
Expand Up @@ -63,7 +63,7 @@ def split(input, pattern)
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
Expand Down
6 changes: 6 additions & 0 deletions test/liquid/filter_test.rb
Expand Up @@ -75,6 +75,12 @@ def test_strip_html
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"

Expand Down

0 comments on commit 515b311

Please sign in to comment.