Django

Code

Ticket #5202 (closed: wontfix)

Opened 1 year ago

Last modified 1 year ago

urlize filter before linebreaks doesn't work correctly

Reported by: chinkanga@gmail.com Assigned to: adrian
Milestone: Component: Template system
Version: 0.96 Keywords: urlize linebreaks
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by mtredinnick)

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?)

Attachments

Change History

08/19/07 02:58:50 changed by mtredinnick

  • needs_better_patch changed.
  • description changed.
  • needs_tests changed.
  • needs_docs changed.

(Tweaked description formatting)

08/19/07 03:46:02 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to wontfix.

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@example.com>', which occurs in plain text sometimes. So the meaning of '<' is overloaded is we try to handle plain text and HTML here.

08/19/07 03:50:51 changed by mtredinnick

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


Add/Change #5202 (urlize filter before linebreaks doesn't work correctly)




Change Properties
Action