diff --git a/product/Formulator/Validator.py b/product/Formulator/Validator.py index 39f427e70c8769f01d770f4fd5fabf6ebe700d0c..fd6ca4aa497cba54e5f507c02254d3cb7eb3e1bc 100644 --- a/product/Formulator/Validator.py +++ b/product/Formulator/Validator.py @@ -387,7 +387,7 @@ class LinesValidator(StringBaseValidator): if max_length and len(value) > max_length: self.raise_error('too_long', field) # split input into separate lines - lines = value.splitlines() + lines = value.replace('\r\n', '\n').split('\n') # check whether we have too many lines max_lines = field.get_value('max_lines') or 0 diff --git a/product/Formulator/tests/testFormValidator.py b/product/Formulator/tests/testFormValidator.py index 0777892fc6abd28f8898a7c2d301ae5fff22bef8..50099e1db41dad6e88eb938da630e2dd89e36821 100644 --- a/product/Formulator/tests/testFormValidator.py +++ b/product/Formulator/tests/testFormValidator.py @@ -460,6 +460,11 @@ class LinesValidatorTestCase(ValidatorTestCase): 'f', {'f' : 'foo\r\nbar '}) 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(): suite = unittest.TestSuite()