Opened 13 years ago

Closed 12 years ago

#17576 closed Bug (wontfix)

Enclosing quotation marks for urlize. (Or make urlize easier to override)

Reported by: Tom Christie Owned by: Tom Christie
Component: Utilities Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

urlize currently allows enclosing brackets. It'd be good if it also allowed enclosing quotation marks. (eg. when calling urlize on JSON output.)

Two possible options:

  1. Add single and double quote pairs to WRAPPING_PUNCTUATION at https://github.com/django/django/blob/master/django/utils/html.py#L15
  2. Add wrapping_punctation=WRAPPING_PUNCTUATION, trailing_punctuation=TRAILING_PUNCTUATiON arguments to urlize to make it possible to override the defaults.

I think either would be reasonable, and both trivial changes.

Attachments (1)

17576.patch (2.0 KB ) - added by Aymeric Augustin 12 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 by Aymeric Augustin, 13 years ago

Triage Stage: UnreviewedAccepted

+0 for option 1.

-1 for option 2, as it would be quite ugly to pass arguments to urlize in a template.

NB: technically, it's already possible to import WRAPPING_PUNCTUATION and TRAILING_PUNCTUATiON and mutate them — but of course they aren't a public API and may change any time, see r17362 for instance.

comment:2 by Aymeric Augustin, 12 years ago

Component: Template systemUtilities

The real question here is -- who's going to consider this change a regression?

comment:3 by Aymeric Augustin, 12 years ago

Resolution: wontfix
Status: newclosed

I implemented option 1, but it doesn't work well on JSON. I'm attaching a patch with a failing test.

The problem is that, in addition to the closing quotation mark, there's usually a comma or a closing bracket, and it isn't be stripped. Clearly urlize isn't designed to handle JSON, and the change doesn't turn out to be trivial.

by Aymeric Augustin, 12 years ago

Attachment: 17576.patch added
Note: See TracTickets for help on using tickets.
Back to Top