Commit c860f1e7 authored by Jérome Perrin's avatar Jérome Perrin

34924 was an incomplete fix, trailing empty line was omitted


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@34950 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 86dd6912
...@@ -387,7 +387,7 @@ class LinesValidator(StringBaseValidator): ...@@ -387,7 +387,7 @@ class LinesValidator(StringBaseValidator):
if max_length and len(value) > max_length: if max_length and len(value) > max_length:
self.raise_error('too_long', field) self.raise_error('too_long', field)
# split input into separate lines # split input into separate lines
lines = value.splitlines() lines = value.replace('\r\n', '\n').split('\n')
# check whether we have too many lines # check whether we have too many lines
max_lines = field.get_value('max_lines') or 0 max_lines = field.get_value('max_lines') or 0
......
...@@ -460,6 +460,11 @@ class LinesValidatorTestCase(ValidatorTestCase): ...@@ -460,6 +460,11 @@ class LinesValidatorTestCase(ValidatorTestCase):
'f', {'f' : 'foo\r\nbar '}) 'f', {'f' : 'foo\r\nbar '})
self.assertEqual(['foo', 'bar '], result) self.assertEqual(['foo', 'bar '], result)
def test_empty_lines(self):
result = self.v.validate(
TestField('f', whitespace_preserve=True),
'f', {'f' : '\r\nfoo\r\n\r\nbar\r\n'})
self.assertEqual(['', 'foo', '', 'bar', ''], result)
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment