#5980: FilterExpression does not properly respect escaped quotes
----------------------------------------------------+-----------------------
Reporter:  Dmitri Fedortchenko <[EMAIL PROTECTED]>  |       Owner:  nobody      
       
  Status:  new                                      |   Component:  Template 
system    
 Version:  SVN                                      |    Keywords:  filter 
quote escape
   Stage:  Unreviewed                               |   Has_patch:  1           
       
----------------------------------------------------+-----------------------
 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.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5980>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to