Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#6048 closed (worksforme)

compile_filter() does not allow quote escaping for constant strings

Reported by: miracle2k Owned by: nobody
Component: Template system Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


{{ "abc \" def" }}
{% mytag with value="abc \" def" %}

In both cases, Parser.compile_filter().resolve() will return the string as

abc \" def

Actually, FilterExpression.init() in django.template, which does the parsing, calls

constant_arg.replace(r'\"', '"'))

when resolving the filter part of the expression - but not for the variable part.

A workaround is:

0|default:"abc \" def"

Change History (2)

comment:1 Changed 13 years ago by Chris Beaven

Resolution: worksforme
Status: newclosed

Seems to work for me...

>>> from django.template import *
>>> c = Context()
>>> t = Template(r'{{ "test \" me" }}')
>>> t.render(c)
u'test " me'

Want to make up some tests which show your problem and reopen?

comment:2 Changed 13 years ago by Malcolm Tredinnick

I'm fairly sure that the difference between the original reporter's observation and Chris' is because the latter's checkout is more up to date. This was only fixed in [6724] (a few hours ago).

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