Code

Ticket #12027: email_re_patch.diff

File email_re_patch.diff, 1.0 KB (added by anonymous, 5 years ago)

Patch of regular expression for email address validation

Line 
1Index: django/forms/fields.py
2===================================================================
3--- django/forms/fields.py      (revision 11620)
4+++ django/forms/fields.py      (arbetskopia)
5@@ -421,7 +421,7 @@
6 email_re = re.compile(
7     r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*"  # dot-atom
8     r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
9-    r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE)  # domain
10+    r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}$', re.IGNORECASE)  # domain
11 
12 class EmailField(RegexField):
13     default_error_messages = {
14@@ -532,7 +532,7 @@
15 
16 url_re = re.compile(
17     r'^https?://' # http:// or https://
18-    r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' #domain...
19+    r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}|' #domain...
20     r'localhost|' #localhost...
21     r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
22     r'(?::\d+)?' # optional port