Ticket #4555: django-unescape.patch
File django-unescape.patch, 2.0 KB (added by , 17 years ago) |
---|
-
tests/regressiontests/defaultfilters/tests.py
171 171 >>> escape(u'<some html & special characters > here ĐÅ€£') 172 172 u'<some html & special characters > here \xc4\x90\xc3\x85\xe2\x82\xac\xc2\xa3' 173 173 174 >>> unescape('<some html & special characters > here') 175 '<some html & special characters > here' 176 177 >>> unescape(u'<some html & special characters > here \xc4\x90\xc3\x85\xe2\x82\xac\xc2\xa3') 178 u'<some html & special characters > here ĐÅ€£' 179 174 180 >>> linebreaks('line 1') 175 181 '<p>line 1</p>' 176 182 -
django/utils/html.py
28 28 html = str(html) 29 29 return html.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''') 30 30 31 def unescape(html): 32 "Returns the given HTML with ampersands, quotes and carets decoded" 33 if not isinstance(html, basestring): 34 html = str(html) 35 return html.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace(''',"'") 36 31 37 def linebreaks(value): 32 38 "Converts newlines into <p> and <br />s" 33 39 value = re.sub(r'\r\n|\r|\n', '\n', value) # normalize newlines -
django/template/defaultfilters.py
259 268 return escape(value) 260 269 escape = stringfilter(escape) 261 270 271 def unescape(value): 272 "Unescapes a string's HTML" 273 from django.utils.html import unescape 274 return unescape(value) 275 unescape = stringfilter(unescape) 276 262 277 def linebreaks(value): 263 278 "Converts newlines into <p> and <br />s" 264 279 from django.utils.html import linebreaks