#30589 closed Cleanup/optimization (fixed)
urlize parses email addresses with apostrophes incorrectly.
Reported by: | Mark Gregson | Owned by: | Pystar |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Shai Berger | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
In 1.11.21 I've observed that the urlize template tag messes up email addresses containing apostrophes in the local part, specifically, it excludes any characters before the apostrophe from the link text and href attribute.
A simple example using django.utils.htmls.urlize:
>>> from django.utils.html import urlize >>> urlize("o'neill@example.com") u'o\'<a href="mailto:neill@example.com">neill@example.com</a>'
I would expect this to return:
u'<a href="mailto:o\'neill@example.com">o\'neill@example.com</a>'
Change History (6)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
Cc: | added |
---|---|
Component: | Template system → Documentation |
Easy pickings: | set |
Summary: | urlize parses email addresses with apostrophes incorrectly → urlize parses email addresses with apostrophes incorrectly. |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
Version: | 1.11 → master |
Thanks for the report. We excluded quotes in the #24471. It seems that only single quotes from the list of allowed special characters are affected. I agree that we can clarify this in the documentation, e.g. Email addresses cannot contain the single quotes (``'``).
Given the range of characters allowed in the local part of an email address is quite extensive and that a quoted local part is also allowed (RFC 3696 has a nice summary https://tools.ietf.org/html/rfc3696#section-3), I realise that there probably need to be some constraints on what range of email addresses
urlize
can parse. Potentially then this issue should be resolved by additional documentation clarifying those constraints.