Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[2.3] [Twig][Bridge]Added escaping for the trans block #6723

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

dlsniper commented Jan 13, 2013

Bug fix: yes
Feature addition: no
Backwards compatibility break: yes
Fixes the following tickets: #2713
Todo: see below
License of the code: MIT
Documentation PR: ~

This fixes an escaping problem with using the {% trans %} block which wasn't escaping the translations. Also I think this applies to the {% transchoice %} block.

Imho since this is such a behavior change, it should be done in master branch. Also I'm not sure about it but I think I must add the change in both upgrade file and documentation.

There's one thing that I don't really like about this, the fact that I've hardcoded the 'html' string as a context but I don't know how to get the context either at compile time or in the compiled template. Any help would be great!

Owner

fabpot commented Feb 1, 2013

The current behavior was done on purpose (and I'm quite sure this is documented that way): a tag never escapes anything. So I'm -1 on this change.

@fabpot fabpot closed this Mar 23, 2013

Member

wouterj commented Mar 23, 2013

This is indeed documented:

Using the translation tags or filters have the same effect, but with one subtle difference: automatic output escaping is only applied to translations using a filter. In other words, if you need to be sure that your translated is not output escaped, you must apply the raw filter after the translation filter:

-- (source)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment