Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#5202 closed (wontfix)

urlize filter before linebreaks doesn't work correctly

Reported by: chinkanga@… Owned by: adrian
Component: Template system Version: 0.96
Severity: Keywords: urlize linebreaks
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by mtredinnick)


p = ""

in template:

{{ p|linebreaks|urlize }}

Your link will not be urlize'd.

However if given (note the line break):

p = "My test
oh boy"

using the same template, in my HTML I get:

<p>My test <a href="" rel="nofollow"><br></a> /&gt;oh boy</p>

It looks like the <br /> is getting broken.

Workaround: switch the order of the filters!

Possible Fixes: Make urlize treat the <br /> nicely. Or consider any angle bracket to be a word boundry (angle brackets aren't valid in URLs anyway, right?)

Change History (3)

comment:1 Changed 8 years ago by mtredinnick

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

(Tweaked description formatting)

comment:2 Changed 8 years ago by mtredinnick

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

Urlize should be applied to plain text (as per the documentation), not text that is already HTML. Reversing the order of the filters is the right way to use urlize and linebreaks in conjunction.

One difficulty is that we don't want to break processing of text that looks like `<mailto:foo@…>', which occurs in plain text sometimes. So the meaning of '<' is overloaded is we try to handle plain text and HTML here.

comment:3 Changed 8 years ago by mtredinnick

(In [5937]) Clarified that urlize and urlizetrunc should only be applied to plain text. Refs #5202.

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