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)
Change History (13)
by , 14 years ago
Attachment: | fix_windows_lineendings_breaking_linebreaksbr.patch added |
---|
comment:2 by , 14 years ago
Needs tests: | set |
---|
comment:3 by , 14 years ago
Owner: | changed from | to
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 13 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
by , 13 years ago
Attachment: | 14288.linebreaksbr-normalized-newlines.diff added |
---|
comment:5 by , 13 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 , 13 years ago
Patch needs improvement: | set |
---|
Please use the utility django.utils.text.normalize_newlines
to do this.
by , 13 years ago
Attachment: | 14288.linebreaksbr-normalized-newlines.2.diff added |
---|
comment:7 by , 13 years ago
Patch needs improvement: | unset |
---|
Thank you, Jannis. I took the chance to make django.utils.html.linebreaks
use it as well.
by , 13 years ago
Attachment: | 14288.linebreaksbr-normalized-newlines.3.diff added |
---|
Patch updated to latest trunk
comment:8 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|---|
UI/UX: | unset |
Patch