Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #5890 -- fixed the far edge-case of allowing constant strings i…

…nside

template template markers: we now treat embedded, escaped double quotes
consistently with constant string arguments to filters. Patch from Dmitri
Fedortchenko.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6724 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9130765ff9823055654207149c051eb2fe7c7165 1 parent 5a5a71e
@malcolmt malcolmt authored
View
4 django/template/__init__.py
@@ -547,9 +547,9 @@ def __init__(self, token, parser):
if var == None:
var, constant, i18n_constant = match.group("var", "constant", "i18n_constant")
if i18n_constant:
- var = '"%s"' % _(i18n_constant)
+ var = '"%s"' % _(i18n_constant.replace(r'\"', '"'))
elif constant:
- var = '"%s"' % constant
+ var = '"%s"' % constant.replace(r'\"', '"')
upto = match.end()
if var == None:
raise TemplateSyntaxError, "Could not find variable at start of %s" % token
View
6 tests/regressiontests/templates/tests.py
@@ -268,6 +268,12 @@ def get_template_tests(self):
# Embedded newlines make it not-a-tag.
'basic-syntax24': ("{{ moo\n }}", {}, "{{ moo\n }}"),
+ # Literal strings are permitted inside variables, mostly for i18n
+ # purposes.
+ 'basic-syntax25': ('{{ "fred" }}', {}, "fred"),
+ 'basic-syntax26': (r'{{ "\"fred\"" }}', {}, "\"fred\""),
+ 'basic-syntax27': (r'{{ _("\"fred\"") }}', {}, "\"fred\""),
+
# List-index syntax allows a template to access a certain item of a subscriptable object.
'list-index01': ("{{ var.1 }}", {"var": ["first item", "second item"]}, "second item"),
Please sign in to comment.
Something went wrong with that request. Please try again.