Skip to content

Commit

Permalink
Merge pull request django#289 from mjtamlyn/slugify-real-function
Browse files Browse the repository at this point in the history
Fixed bug in 212b982 -- Removed duplicate code in removetags
  • Loading branch information
andrewgodwin committed Aug 18, 2012
2 parents 5b09fc8 + e498481 commit bf12c66
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions django/template/defaultfilters.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,8 @@ def safeseq(value):
@stringfilter
def removetags(value, tags):
"""Removes a space separated list of [X]HTML tags from the output."""
tags = [re.escape(tag) for tag in tags.split()]
tags_re = '(%s)' % '|'.join(tags)
starttag_re = re.compile(r'<%s(/?>|(\s+[^>]*>))' % tags_re, re.U)
endtag_re = re.compile('</%s>' % tags_re)
value = starttag_re.sub('', value)
value = endtag_re.sub('', value)
return value
from django.utils.html import remove_tags
return remove_tags(value, tags)

@register.filter(is_safe=True)
@stringfilter
Expand Down

0 comments on commit bf12c66

Please sign in to comment.