Commits

mtre...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed 6c17fd4

unicode: Fixed #4662 -- Fixed a remaining ASCII assumption in
truncatewords_html(). Thanks, Ivan Sagalaev.

  • Participants
  • Parent commits 1b6b4ae
  • Branches unicode

Comments (0)

Files changed (2)

File django/utils/text.py

         return u''
     html4_singlets = ('br', 'col', 'link', 'base', 'img', 'param', 'area', 'hr', 'input')
     # Set up regular expressions
-    re_words = re.compile(r'&.*?;|<.*?>|([A-Za-z0-9][\w-]*)')
+    re_words = re.compile(r'&.*?;|<.*?>|(\w[\w-]*)', re.U)
     re_tag = re.compile(r'<(/)?([^ ]+?)(?: (/)| .*?)?>')
     # Count non-HTML words and keep note of open tags
     pos = 0

File tests/regressiontests/defaultfilters/tests.py

 >>> truncatewords_html(u'<p>one <a href="#">two - three <br>four</a> five</p>', 100)
 u'<p>one <a href="#">two - three <br>four</a> five</p>'
 
+>>> truncatewords_html(u'\xc5ngstr\xf6m was here', 1)
+u'\xc5ngstr\xf6m ...'
+
 >>> upper(u'Mixed case input')
 u'MIXED CASE INPUT'