Ticket #14288: fix_windows_lineendings_breaking_linebreaksbr.patch
File fix_windows_lineendings_breaking_linebreaksbr.patch, 1.2 KB (added by , 14 years ago) |
---|
-
django/template/defaultfilters.py
426 426 Converts all newlines in a piece of plain text to HTML line breaks 427 427 (``<br />``). 428 428 """ 429 value = re.sub(r'\r\n|\r|\n', '\n', force_unicode(value)) # normalize newlines 429 430 if autoescape and not isinstance(value, SafeData): 430 431 from django.utils.html import escape 431 432 value = escape(value) -
tests/regressiontests/defaultfilters/tests.py
266 266 >>> linebreaks(u'line 1\nline 2') 267 267 u'<p>line 1<br />line 2</p>' 268 268 269 >>> linebreaks(u'line 1\r\nline 2') 270 u'<p>line 1<br />line 2</p>' 271 272 >>> linebreaksbr(u'line 1\nline 2') 273 u'line 1<br />line 2' 274 275 >>> linebreaksbr(u'line 1\r\nline 2') 276 u'line 1<br />line 2' 277 269 278 >>> removetags(u'some <b>html</b> with <script>alert("You smell")</script> disallowed <img /> tags', 'script img') 270 279 u'some <b>html</b> with alert("You smell") disallowed tags' 271 280