diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 60fa59e..5c9e0f7 100644
a
|
b
|
def linebreaksbr(value, autoescape=None):
|
414 | 414 | Converts all newlines in a piece of plain text to HTML line breaks |
415 | 415 | (``<br />``). |
416 | 416 | """ |
417 | | if autoescape and not isinstance(value, SafeData): |
| 417 | autoescape = autoescape and not isinstance(value, SafeData) |
| 418 | value = re.sub(r'\r\n|\r|\n', '\n', force_unicode(value)) # normalize newlines |
| 419 | if autoescape: |
418 | 420 | from django.utils.html import escape |
419 | 421 | value = escape(value) |
420 | 422 | return mark_safe(value.replace('\n', '<br />')) |
diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py
index 77bd2ba..b471205 100644
a
|
b
|
class DefaultFiltersTests(TestCase):
|
266 | 266 | self.assertEqual(linebreaks(u'line 1'), u'<p>line 1</p>') |
267 | 267 | self.assertEqual(linebreaks(u'line 1\nline 2'), |
268 | 268 | u'<p>line 1<br />line 2</p>') |
| 269 | self.assertEqual(linebreaks(u'line 1\rline 2'), |
| 270 | u'<p>line 1<br />line 2</p>') |
| 271 | self.assertEqual(linebreaks(u'line 1\r\nline 2'), |
| 272 | u'<p>line 1<br />line 2</p>') |
| 273 | |
| 274 | def test_linebreaksbr(self): |
| 275 | self.assertEqual(linebreaksbr(u'line 1\nline 2'), |
| 276 | u'line 1<br />line 2') |
| 277 | self.assertEqual(linebreaksbr(u'line 1\rline 2'), |
| 278 | u'line 1<br />line 2') |
| 279 | self.assertEqual(linebreaksbr(u'line 1\r\nline 2'), |
| 280 | u'line 1<br />line 2') |
269 | 281 | |
270 | 282 | def test_removetags(self): |
271 | 283 | self.assertEqual(removetags(u'some <b>html</b> with <script>alert'\ |