Opened 17 years ago

Closed 17 years ago

Last modified 17 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)

given:

p = "www.example.com"

in template:

{{ p|linebreaks|urlize }}

Your link will not be urlize'd.

However if given (note the line break):

p = "My test www.example.com
oh boy"

using the same template, in my HTML I get:

<p>My test <a href="http://www.example.com%3Cbr" rel="nofollow">www.example.com<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 by Malcolm Tredinnick, 17 years ago

Description: modified (diff)

(Tweaked description formatting)

comment:2 by Malcolm Tredinnick, 17 years ago

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

(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