Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#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 Mark Gregson, 6 years ago

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.

comment:2 by Mariusz Felisiak, 6 years ago

Cc: Shai Berger added
Component: Template systemDocumentation
Easy pickings: set
Summary: urlize parses email addresses with apostrophes incorrectlyurlize parses email addresses with apostrophes incorrectly.
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization
Version: 1.11master

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 (``'``).

comment:3 by Pystar, 5 years ago

Owner: changed from nobody to Pystar
Status: newassigned

I will work on this.

comment:5 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In c2f381e:

Fixed #30589 -- Clarified that urlize should be applied only to email addresses without single quotes.

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In b9d1bb69:

[2.2.x] Fixed #30589 -- Clarified that urlize should be applied only to email addresses without single quotes.

Backport of c2f381ef17058e5cfea58ae507983d2e459a2888 from master

Note: See TracTickets for help on using tickets.
Back to Top