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

Comments

Projects
None yet
6 participants
@Tobion
Copy link
Member

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

This comment has been minimized.

Copy link
Contributor

commented Nov 24, 2011

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

This comment has been minimized.

Copy link
Member Author

commented Nov 24, 2011

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

@dlsniper

This comment has been minimized.

Copy link
Contributor

commented Jan 12, 2013

@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

This comment has been minimized.

Copy link
Member

commented Jan 12, 2013

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

@fabpot

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

commented Jan 21, 2013

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

@stof

This comment has been minimized.

Copy link
Member

commented Jan 22, 2013

@wouterj yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.