Ticket #7267: clean_html_unicode_r7601.patch

File clean_html_unicode_r7601.patch, 1.3 KB (added by George Vilches, 16 years ago)

Patch against r7601 to fix crash error with clean_html.

  • django/utils/html.py

     
    1313TRAILING_PUNCTUATION = ['.', ',', ')', '>', '\n', '>']
    1414
    1515# List of possible strings used for bullets in bulleted lists.
    16 DOTS = ['·', '*', '\xe2\x80\xa2', '•', '•', '•']
     16DOTS = [u'·', u'*', u'\xe2\x80\xa2', u'•', u'•', u'•']
    1717
    1818unencoded_ampersands_re = re.compile(r'&(?!(\w+|#\d+);)')
    1919word_split_re = re.compile(r'(\s+)')
     
    151151    text = html_gunk_re.sub('', text)
    152152    # Convert hard-coded bullets into HTML unordered lists.
    153153    def replace_p_tags(match):
    154         s = match.group().replace('</p>', '</li>')
     154        s = match.group().replace(u'</p>', u'</li>')
    155155        for d in DOTS:
    156             s = s.replace('<p>%s' % d, '<li>')
     156            s = s.replace(u'<p>%s' % d, u'<li>')
    157157        return u'<ul>\n%s\n</ul>' % s
    158158    text = hard_coded_bullets_re.sub(replace_p_tags, text)
    159159    # Remove stuff like "<p>&nbsp;&nbsp;</p>", but only if it's at the bottom
    160160    # of the text.
    161     text = trailing_empty_content_re.sub('', text)
     161    text = trailing_empty_content_re.sub(u'', text)
    162162    return text
    163163clean_html = allow_lazy(clean_html, unicode)
Back to Top