Changeset 4919
- Timestamp:
- 04/04/07 01:43:28 (2 years ago)
- Files:
-
- django/trunk/django/utils/html.py (modified) (2 diffs)
- django/trunk/tests/regressiontests/defaultfilters/tests.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/utils/html.py
r4885 r4919 2 2 3 3 import re, string 4 from django.utils.encoding import smart_unicode 4 5 5 6 # Configuration for urlize() function … … 25 26 "Returns the given HTML with ampersands, quotes and carets encoded" 26 27 if not isinstance(html, basestring): 27 html = s tr(html)28 html = smart_unicode(html) 28 29 return html.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''') 29 30 django/trunk/tests/regressiontests/defaultfilters/tests.py
r4753 r4919 1 # -*- coding: utf-8 -*- 2 1 3 r""" 2 4 >>> floatformat(7.7) … … 88 90 'A sentence with a few words in it' 89 91 90 >>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 0) 91 '' 92 93 >>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 2) 92 >>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 0) 93 '' 94 95 >>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 2) 94 96 '<p>one <a href="#">two ...</a></p>' 95 96 >>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 4) 97 98 >>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 4) 97 99 '<p>one <a href="#">two - three <br>four ...</a></p>' 98 100 99 >>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 5) 101 >>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 5) 100 102 '<p>one <a href="#">two - three <br>four</a> five</p>' 101 103 102 >>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 100) 104 >>> truncatewords_html('<p>one <a href="#">two - three <br>four</a> five</p>', 100) 103 105 '<p>one <a href="#">two - three <br>four</a> five</p>' 104 106 … … 166 168 >>> escape('<some html & special characters > here') 167 169 '<some html & special characters > here' 170 171 >>> escape(u'<some html & special characters > here ĐÅ€£') 172 u'<some html & special characters > here \xc4\x90\xc3\x85\xe2\x82\xac\xc2\xa3' 168 173 169 174 >>> linebreaks('line 1')
