Opened 4 years ago

Closed 3 years ago

#17576 closed Bug (wontfix)

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

Reported by: tomchristie Owned by: tomchristie
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


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
  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 aaugustin 3 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 4 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

+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 Changed 3 years ago by aaugustin

  • Component changed from Template system to Utilities

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

comment:3 Changed 3 years ago by aaugustin

  • Resolution set to wontfix
  • Status changed from new to closed

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.

Changed 3 years ago by aaugustin

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