Opened 10 years ago

Closed 10 years ago

#2215 closed enhancement (wontfix)

[patch] django.utils.html.escape does not escape non-english characters properly

Reported by: Matias Hermanrud Fjeld <mhf@…> Owned by: Adrian Holovaty
Component: Tools Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This patch makes django.utils.html.escape use pythons htmlentitydefs module to know what to escape.

Characters like æ, ø, å and alot of other non-english letters are escaped properly:

>>> from django.utils.html import escape
>>> escape('<p>æøå</p>')
'&lt;p&gt;&aelig;&oslash;&aring;&lt;/p&gt;'

It would be nice to use generators here, but alas.

Attachments (1)

django-escape.diff (1.1 KB) - added by Matias Hermanrud Fjeld <mhf@…> 10 years ago.

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by Matias Hermanrud Fjeld <mhf@…>

Attachment: django-escape.diff added

comment:1 Changed 10 years ago by Matias Hermanrud Fjeld <mhf@…>

Summary: [patch] django.utils.html.escape does not escape non-english characers properly[patch] django.utils.html.escape does not escape non-english characters properly

comment:2 Changed 10 years ago by Jacob

Resolution: wontfix
Status: newclosed

Entities don't need to be "escaped" to be used in HTML as long as you've got the right encoding. This might be worth added as a seperate filter, but it doesn't belong in escape.

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