Skip to content

[TwigBridge] Allow label translation to be safe #25744

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

Merged
merged 1 commit into from
Jan 30, 2018
Merged

[TwigBridge] Allow label translation to be safe #25744

merged 1 commit into from
Jan 30, 2018

Conversation

MatTheCat
Copy link
Contributor

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? ~
Fixed tickets ~
License MIT
Doc PR ~

After overriding TranslationExtension's trans filter to make it safe I noticed form labels were still escaped because of label in

{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}

Replacing this ternary with if/else allows trans return to be safe.

WDYT?

@MatTheCat MatTheCat changed the base branch from master to 2.7 January 10, 2018 12:28
@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Jan 10, 2018
@MatTheCat
Copy link
Contributor Author

Guess I'll have to override the form theme.

@MatTheCat MatTheCat closed this Jan 17, 2018
@MatTheCat
Copy link
Contributor Author

Well I'd like to hear something though.

@MatTheCat MatTheCat reopened this Jan 24, 2018
@MatTheCat
Copy link
Contributor Author

Ping @nicolas-grekas you're the only one who interacted with this PR.

@fabpot
Copy link
Member

fabpot commented Jan 30, 2018

Thank you @MatTheCat.

@fabpot fabpot merged commit 041c42d into symfony:2.7 Jan 30, 2018
fabpot added a commit that referenced this pull request Jan 30, 2018
This PR was merged into the 2.7 branch.

Discussion
----------

[TwigBridge] Allow label translation to be safe

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | ~
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

After overriding `TranslationExtension`'s `trans` filter to make it safe I noticed form labels were still escaped because of `label` in

```twig
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}
```

Replacing this ternary with `if`/`else` allows `trans` return to be safe.

WDYT?

Commits
-------

041c42d Allow trans filter to be safe
@MatTheCat MatTheCat deleted the safe_label branch April 30, 2018 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants