Opened 13 years ago

Closed 12 years ago

#15683 closed Cleanup/optimization (fixed)

the force_escpe filter should not call mark_safe

Reported by: Germano Gabbianelli Owned by: Marcos Moyano
Component: Template system Version: 1.3
Severity: Normal Keywords: force_escape mark_safe
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

in template.defaultfilters.force_escape you are explicitly calling mark_safe on the value returned by utils.html.escape, but escape already calls mark_safe on the string it returns
http://code.djangoproject.com/browser/django/trunk/django/utils/html.py#L30
http://code.djangoproject.com/browser/django/trunk/django/template/defaultfilters.py#L391

I reported this on #django-dev and got answered:

<carljm> tyrion-mx: indeed, i think the mark_safe in force_escape is unnecessary. though also harmless - it costs exactly one function call and one isinstance check.

Attachments (1)

ticket_15683.patch (450 bytes ) - added by Marcos Moyano 13 years ago.
remove marke_safe

Download all attachments as: .zip

Change History (10)

comment:1 by Luke Plant, 13 years ago

Triage Stage: UnreviewedAccepted

by Marcos Moyano, 13 years ago

Attachment: ticket_15683.patch added

remove marke_safe

comment:2 by Marcos Moyano, 13 years ago

Owner: changed from nobody to Marcos Moyano
Status: newassigned

comment:3 by Marcos Moyano, 13 years ago

Has patch: set
Needs tests: set

comment:4 by Luke Plant, 13 years ago

Type: Cleanup/optimization

comment:5 by Luke Plant, 13 years ago

Severity: Normal

comment:6 by Jannis Leidel, 13 years ago

Easy pickings: unset
Triage Stage: AcceptedReady for checkin

comment:7 by Jannis Leidel, 13 years ago

Triage Stage: Ready for checkinAccepted

back to accepted since tests are missing..

comment:8 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:9 by Claude Paroz, 12 years ago

Resolution: fixed
Status: assignedclosed

In [17876]:

Fixed #15683 -- Prevented escaped string to be needlessly marked safe twice in force_escape filter. Thanks tyrion for the initial patch.

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