diff --git a/django/core/validators.py b/django/core/validators.py
index cc71b72..8655266 100644
a
|
b
|
class RegexValidator(object):
|
58 | 58 | class URLValidator(RegexValidator): |
59 | 59 | regex = re.compile( |
60 | 60 | r'^(?:[a-z0-9\.\-]*)://' # scheme is validated separately |
61 | | r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain... |
| 61 | r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}(?<!-)\.?)|' # domain... |
62 | 62 | r'localhost|' # localhost... |
63 | 63 | r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|' # ...or ipv4 |
64 | 64 | r'\[?[A-F0-9]*:[A-F0-9:]+\]?)' # ...or ipv6 |
… |
… |
class EmailValidator(object):
|
114 | 114 | r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)', # quoted-string |
115 | 115 | re.IGNORECASE) |
116 | 116 | domain_regex = re.compile( |
117 | | r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,})$', |
| 117 | r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,}(?<!-))$', |
118 | 118 | re.IGNORECASE) |
119 | 119 | literal_regex = re.compile( |
120 | 120 | # literal form, ipv4 or ipv6 address (SMTP 4.1.3) |
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index 928c482..9330ab5 100644
a
|
b
|
TEST_DATA = (
|
58 | 58 | (validate_email, 'email@[::ffff:127.0.0.256]', ValidationError), |
59 | 59 | (validate_email, 'example@invalid-.com', ValidationError), |
60 | 60 | (validate_email, 'example@-invalid.com', ValidationError), |
| 61 | (validate_email, 'example@invalid.com-', ValidationError), |
61 | 62 | (validate_email, 'example@inv-.alid-.com', ValidationError), |
62 | 63 | (validate_email, 'example@inv-.-alid.com', ValidationError), |
63 | 64 | (validate_email, 'test@example.com\n\n<script src="x.js">', ValidationError), |
… |
… |
TEST_DATA = (
|
174 | 175 | (URLValidator(), 'http://.com', ValidationError), |
175 | 176 | (URLValidator(), 'http://invalid-.com', ValidationError), |
176 | 177 | (URLValidator(), 'http://-invalid.com', ValidationError), |
| 178 | (URLValidator(), 'http://invalid.com-', ValidationError), |
177 | 179 | (URLValidator(), 'http://inv-.alid-.com', ValidationError), |
178 | 180 | (URLValidator(), 'http://inv-.-alid.com', ValidationError), |
179 | 181 | (URLValidator(), 'file://localhost/path', ValidationError), |