diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index 061988c..c4a2792 100644
a
|
b
|
from django.utils.html import conditional_escape, format_html, format_html_join
|
19 | 19 | from django.utils.translation import ugettext, ugettext_lazy |
20 | 20 | from django.utils.encoding import force_text, python_2_unicode_compatible |
21 | 21 | from django.utils.safestring import mark_safe |
| 22 | from django.utils.text import normalize_newlines |
22 | 23 | from django.utils import datetime_safe, formats, six |
23 | 24 | |
24 | 25 | __all__ = ( |
… |
… |
class ClearableFileInput(FileInput):
|
392 | 393 | return False |
393 | 394 | return upload |
394 | 395 | |
| 396 | |
395 | 397 | class Textarea(Widget): |
396 | 398 | def __init__(self, attrs=None): |
397 | 399 | # The 'rows' and 'cols' attributes are required for HTML correctness. |
… |
… |
class Textarea(Widget):
|
407 | 409 | flatatt(final_attrs), |
408 | 410 | force_text(value)) |
409 | 411 | |
| 412 | def value_from_datadict(self, data, files, name): |
| 413 | value = super(Textarea, self).value_from_datadict(data, files, name) |
| 414 | return normalize_newlines(value) |
| 415 | |
410 | 416 | |
411 | 417 | class DateInput(TextInput): |
412 | 418 | def __init__(self, attrs=None, format=None): |
diff --git a/tests/regressiontests/forms/tests/widgets.py b/tests/regressiontests/forms/tests/widgets.py
index 88469a7..9e1690a 100644
a
|
b
|
class FormsWidgetTestCase(TestCase):
|
183 | 183 | |
184 | 184 | self.assertHTMLEqual(w.render('msg', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}), '<textarea rows="10" cols="40" name="msg" class="fun">\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111</textarea>') |
185 | 185 | |
| 186 | # Test that newlines are normalized to LF |
| 187 | self.assertEqual(w.value_from_datadict({'test': "Content\r\nwith\r\nCRLF"}, {}, 'test'), |
| 188 | "Content\nwith\nCRLF") |
| 189 | self.assertEqual(w.value_from_datadict({'test': "Content\rwith\rCR"}, {}, 'test'), |
| 190 | "Content\nwith\nCR") |
| 191 | self.assertEqual(w.value_from_datadict({'test': "Content\nwith\nLF"}, {}, 'test'), |
| 192 | "Content\nwith\nLF") |
| 193 | |
186 | 194 | def test_checkboxinput(self): |
187 | 195 | w = CheckboxInput() |
188 | 196 | self.assertHTMLEqual(w.render('is_cool', ''), '<input type="checkbox" name="is_cool" />') |