Opened 9 years ago

Closed 9 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
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@…> 9 years ago.

Download all attachments as: .zip

Change History (3)

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

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

  • Summary changed from [patch] django.utils.html.escape does not escape non-english characers properly to [patch] django.utils.html.escape does not escape non-english characters properly

comment:2 Changed 9 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

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