Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#5202 closed (wontfix)

urlize filter before linebreaks doesn't work correctly

Reported by: chinkanga@… Owned by: Adrian Holovaty
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: no UI/UX: no

Description (last modified by Malcolm Tredinnick)


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 11 years ago by Malcolm Tredinnick

Description: modified (diff)

(Tweaked description formatting)

comment:2 Changed 11 years ago by Malcolm Tredinnick

Resolution: wontfix
Status: newclosed

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 11 years ago by Malcolm Tredinnick

(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