Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation escaping #2713

Closed
Tobion opened this issue Nov 24, 2011 · 7 comments
Closed

Translation escaping #2713

Tobion opened this issue Nov 24, 2011 · 7 comments

Comments

@Tobion
Copy link
Contributor

Tobion commented Nov 24, 2011

I know we discussed this earlier, but I'm still or again confused.
The documentation at http://symfony.com/doc/current/book/translation.html says

{# but static strings are never escaped #}
{{ '<h3>foo</h3>' | trans }}

which is wrong. Because it does get escaped. This is strange because the trans tag does on the other hand not escape.
So we get 2 different results for semantically the same stuff:

{% block title 'Me &amp; you'|trans %}

is different from

{% block title %}
{% trans %}Me &amp; you{% endtrans %}
{% endblock %}
@stloyd
Copy link
Contributor

stloyd commented Nov 24, 2011

{{ '<h3>foo</h3>'|trans|raw }}

@Tobion
Copy link
Contributor Author

Tobion commented Nov 24, 2011

I know but that does not resolve the documentation error or the Symfony bug.

@dlsniper
Copy link
Contributor

@Tobion I could work on this but I'd rather know which approach should I take:

  • fix the |trans method
  • fix the {%trans%} method

Thanks!

@stof
Copy link
Member

stof commented Jan 12, 2013

|trans behaves the right way IMO. There is absolutely no reason to consider that the translation string is safe.

@fabpot
Copy link
Member

fabpot commented Jan 21, 2013

And the trans tag also works the right way as content outside expressions are never escaped by Twig. This is even documented. It's probably confusing but I'm against changing the current behavior at this point as it would be a major BC break.

I discussed that with @weaverryan a long time ago but I don't find the issue right now.

@wouterj
Copy link
Member

wouterj commented Jan 21, 2013

If I understand this correct, we should change the documentation, saying that '<h3>foo</h3>|trans' get escaped?

@stof
Copy link
Member

stof commented Jan 22, 2013

@wouterj yes

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

No branches or pull requests

6 participants