﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
5980	FilterExpression does not properly respect escaped quotes	Dmitri Fedortchenko <zeraien@…>	nobody	"FilterExpression does not treat escaped quotes in constant strings properly, unless they are filter arguments.

Consider this:
{{{
#!python

{{ _(""This is an \""object\"""")|filter:""Some\""thing\"""" }} 

{{ ""This is an \""object\""""|filter:""Some\""thing\"""" }} 

}}}
The translation will be run as
{{{
gettext('This is an \""object\""')
}}}
and thus fail, and the constant will be printed as
{{{
This is an \""object\""
}}}

The filter argument on the other hand is properly treated and the escape char is removed from the quotes.

The code below leads me to believe that this is an oversight and not a feature:

Filter arguments are processed here:
{{{
#!python
                if i18n_arg:
                    args.append((False, _(i18n_arg.replace(r'\""', '""'))))
                elif constant_arg is not None:
                    args.append((False, constant_arg.replace(r'\""', '""')))
}}}
and the main string of this expression is processed here:
{{{
#!python
                if i18n_constant:
                    var = '""%s""' % _(i18n_constant)
                elif constant:
                    var = '""%s""' % constant
}}}

This is in the constructor of django.template.FilterExpression. Escaped quotes in filter arguments are be treated, but not escaped quotes in the main string of this expression.


A tiny patch addresses this issue."		closed	Template system	dev		fixed	filter quote escape		Unreviewed	1	0	0	0	0	0
