Browse files

unicode: Fixed #4662 -- Fixed a remaining ASCII assumption in

truncatewords_html(). Thanks, Ivan Sagalaev.


git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5533 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 9c59947 commit daaa3a1dde1d400d57206b258ae62282521461c3 @malcolmt malcolmt committed Jun 25, 2007
Showing with 4 additions and 1 deletion.
  1. +1 −1 django/utils/text.py
  2. +3 −0 tests/regressiontests/defaultfilters/tests.py
View
2 django/utils/text.py
@@ -59,7 +59,7 @@ def truncate_html_words(s, num):
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
View
3 tests/regressiontests/defaultfilters/tests.py
@@ -104,6 +104,9 @@
>>> 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'

0 comments on commit daaa3a1

Please sign in to comment.