summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-06-25 13:11:10 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-06-25 13:11:10 +0000
commitdaaa3a1dde1d400d57206b258ae62282521461c3 (patch)
treea3365188549e350599236963126f445c54a8088e
parent9c5994743c16fba36ead6811973e99e1e742dd8a (diff)
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
-rw-r--r--django/utils/text.py2
-rw-r--r--tests/regressiontests/defaultfilters/tests.py3
2 files changed, 4 insertions, 1 deletions
diff --git a/django/utils/text.py b/django/utils/text.py
index 979775be77..c41c35151b 100644
--- a/django/utils/text.py
+++ b/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
diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py
index 53a92edaed..dc3693f0d6 100644
--- a/tests/regressiontests/defaultfilters/tests.py
+++ b/tests/regressiontests/defaultfilters/tests.py
@@ -104,6 +104,9 @@ u'<p>one <a href="#">two - three <br>four</a> five</p>'
>>> 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'