#3989: Django seems to parse only the addr-spec production of RFC 2822
-------------------------------------------------------------+--------------
Reporter: Pierre Thierry <[EMAIL PROTECTED]> | Owner:
adrian
Status: new |
Component: Validators
Version: SVN |
Resolution:
Keywords: |
Stage: Accepted
Has_patch: 1 |
Needs_docs: 1
Needs_tests: 0 |
Needs_better_patch: 1
-------------------------------------------------------------+--------------
Comment (by Vinay Sajip <[EMAIL PROTECTED]>):
Nothing especially - though I find it easier and quicker to test regexes
with the approach I used, since I can try different combinations of
grouping and alternatives without accidentally stepping on the components
of the regex.
We don't even need re.VERBOSE, since we can use the feature that a
sequence of string literals is concatenated by the compiler into a single
string. Assuming we can keep ADDR_SPEC because of DRY, then the re
becomes:
{{{
ADDR_SPEC = (
"((?:"
r"[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(?:\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*"
# dot-atom
")|(?:"
r'"(?:[\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-
011\013\014\016-\177])*"' # quoted-string
"))@("
r'(?:[A-Z0-9-]+\.)+[A-Z]{2,6}' #domain
")"
)
email_re = re.compile(
"^(?:" + ADDR_SPEC + ")|(?:\w[\w ]*)<" + ADDR_SPEC + ">$",
re.IGNORECASE)
}}}
If it's generally felt that this is equally readable, then I see no
problem going with it.
--
Ticket URL: <http://code.djangoproject.com/ticket/3989#comment:11>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---