Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#22941 closed Bug (fixed)

Add support for urls with no prefix (www/http(s)) and chars after the TLD to django.utils.html urlize.

Reported by: LarryBrid Owned by: LarryBrid
Component: Utilities Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently the urlize template tag will convert the following text into clickable links:

www.google.com/foo
http://google.com/foo
google.com

It will not convert the following into a clickable link:

google.com/foo

The current regex that handles this operation can be found here.

This patch proposes matching all chars after the TLD so that google.com/foo will be converted.

The urlize function handles the removal of cruft from the end of urls prior to running that regex, so the matching of all chars after the TLD shouldn't run the risk of including any unintended chars.

All tests are passing using sql lite, and it should be backward compatible as it doesn't really change anything except for what it is matching. It shouldn't require a documentation change, because it seems like this was the intended behavior according to the current documentation.

Change History (4)

comment:1 by LarryBrid, 10 years ago

This branch modifies the regex from its current for to ...net|org)(.*)$' in order to match chars after the closing TLD.

Version 0, edited 10 years ago by LarryBrid (next)

comment:2 by LarryBrid, 10 years ago

Owner: changed from nobody to LarryBrid
Status: newassigned

comment:3 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In a93ee5112d42d37187e30aa4edcc1864a79d384a:

Fixed #22941 - Added support for domain-only links with chars after the TLD to urlize.

It now works with something like google.com/foo/bar

comment:4 by Claude Paroz <claude@…>, 10 years ago

In 1bb1d3168b813e050df757ff40cdaf2feab45fdb:

Updated urlize regex following a93ee5112d4

Prevent urlize from turning some.organization, an.intern etc.
into urls. Refs #22941.

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