|
25 | 25 | (validate_integer, '42', None), |
26 | 26 | (validate_integer, '-42', None), |
27 | 27 | (validate_integer, -42, None), |
28 | | - (validate_integer, -42.5, None), |
29 | 28 |
|
| 29 | + (validate_integer, -42.5, ValidationError), |
30 | 30 | (validate_integer, None, ValidationError), |
31 | 31 | (validate_integer, 'a', ValidationError), |
| 32 | + (validate_integer, '\n42', ValidationError), |
| 33 | + (validate_integer, '42\n', ValidationError), |
32 | 34 |
|
33 | 35 | ( validate_email, '[email protected]', None), |
34 | 36 | ( validate_email, '[email protected]', None), |
|
66 | 68 | (validate_email, '"\\\011"@here.com', None), |
67 | 69 | (validate_email, '"\\\012"@here.com', ValidationError), |
68 | 70 | ( validate_email, '[email protected].', ValidationError), |
| 71 | + # Trailing newlines in username or domain not allowed |
| 72 | + ( validate_email, '[email protected]\n', ValidationError), |
| 73 | + (validate_email, 'a\n@b.com', ValidationError), |
| 74 | + (validate_email, '"test@test"\n@example.com', ValidationError), |
| 75 | + (validate_email, 'a@[127.0.0.1]\n', ValidationError), |
69 | 76 |
|
70 | 77 | (validate_slug, 'slug-ok', None), |
71 | 78 | (validate_slug, 'longer-slug-still-ok', None), |
|
78 | 85 | ( validate_slug, '[email protected]', ValidationError), |
79 | 86 | (validate_slug, '你好', ValidationError), |
80 | 87 | (validate_slug, '\n', ValidationError), |
| 88 | + (validate_slug, 'trailing-newline\n', ValidationError), |
81 | 89 |
|
82 | 90 | (validate_ipv4_address, '1.1.1.1', None), |
83 | 91 | (validate_ipv4_address, '255.0.0.0', None), |
|
87 | 95 | (validate_ipv4_address, '25.1.1.', ValidationError), |
88 | 96 | (validate_ipv4_address, '25,1,1,1', ValidationError), |
89 | 97 | (validate_ipv4_address, '25.1 .1.1', ValidationError), |
| 98 | + (validate_ipv4_address, '1.1.1.1\n', ValidationError), |
90 | 99 |
|
91 | 100 | # validate_ipv6_address uses django.utils.ipv6, which |
92 | 101 | # is tested in much greater detail in its own testcase |
|
120 | 129 | (validate_comma_separated_integer_list, '', ValidationError), |
121 | 130 | (validate_comma_separated_integer_list, 'a,b,c', ValidationError), |
122 | 131 | (validate_comma_separated_integer_list, '1, 2, 3', ValidationError), |
| 132 | + (validate_comma_separated_integer_list, '1,2,3\n', ValidationError), |
123 | 133 |
|
124 | 134 | (MaxValueValidator(10), 10, None), |
125 | 135 | (MaxValueValidator(10), -10, None), |
|
181 | 191 | (URLValidator(), 'file://localhost/path', ValidationError), |
182 | 192 | (URLValidator(), 'git://example.com/', ValidationError), |
183 | 193 | (URLValidator(EXTENDED_SCHEMES), 'git://-invalid.com', ValidationError), |
| 194 | + # Trailing newlines not accepted |
| 195 | + (URLValidator(), 'http://www.djangoproject.com/\n', ValidationError), |
| 196 | + (URLValidator(), 'http://[::ffff:192.9.5.5]\n', ValidationError), |
184 | 197 |
|
185 | 198 | (BaseValidator(True), True, None), |
186 | 199 | (BaseValidator(True), False, ValidationError), |
|
0 commit comments