Opened 14 years ago

Closed 13 years ago

#14288 closed Bug (fixed)

Template filter: linebreaksbr doesn't normalize newlines

Reported by: Michiel Owned by: nobody
Component: Template system Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When linebreakbr filter encounters windows style newlines it leaves "Carriage return" behind.

Example Code

from django.template.defaultfilters import linebreaksbr
linebreaksbr(u'line 1\r\nline 2')

u'line 1\r<br />line 2'
which should be:
u'line 1\<br />line 2'

Attachments (4)

fix_windows_lineendings_breaking_linebreaksbr.patch (1.2 KB ) - added by Michiel 14 years ago.
Patch
14288.linebreaksbr-normalized-newlines.diff (1.9 KB ) - added by Julien Phalip 14 years ago.
14288.linebreaksbr-normalized-newlines.2.diff (3.0 KB ) - added by Julien Phalip 14 years ago.
14288.linebreaksbr-normalized-newlines.3.diff (3.2 KB ) - added by Julien Phalip 14 years ago.
Patch updated to latest trunk

Download all attachments as: .zip

Change History (13)

comment:1 by Daniel F Moisset, 14 years ago

Owner: changed from nobody to Daniel F Moisset

triaging...

comment:2 by Daniel F Moisset, 14 years ago

Needs tests: set

comment:3 by Daniel F Moisset, 14 years ago

Owner: changed from Daniel F Moisset to nobody
Triage Stage: UnreviewedAccepted

comment:4 by Julien Phalip, 14 years ago

Severity: Normal
Type: Bug

by Julien Phalip, 14 years ago

comment:5 by Julien Phalip, 14 years ago

Easy pickings: unset
Needs tests: unset

The original patch had some issues as the autoescape option was determined after the newline normalisation. The new patch fixes that and adds a couple more tests.

comment:6 by Jannis Leidel, 14 years ago

Patch needs improvement: set

Please use the utility django.utils.text.normalize_newlines to do this.

comment:7 by Julien Phalip, 14 years ago

Patch needs improvement: unset

Thank you, Jannis. I took the chance to make django.utils.html.linebreaks use it as well.

by Julien Phalip, 14 years ago

Patch updated to latest trunk

comment:8 by Jannis Leidel, 13 years ago

Triage Stage: AcceptedReady for checkin
UI/UX: unset

comment:9 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

In [16573]:

Fixed #14288 -- Fixed linebreaksbr template filter to normalize newlines first. Thanks, Julien Phalip.

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