Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix double escaping of the decision attributes in the profiler #21387

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 24, 2017

Conversation

stof
Copy link
Member

@stof stof commented Jan 24, 2017

Q A
Branch? 3.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #21384
License MIT
Doc PR n/a

A ternary operator is considered safe by the Twig auto-escaping only when both branches are safe. But this ternary was safe only in the ELSE branch, causing it to be unsafe. This triggered a double-escaping of the value (escaping the output of the dump). The fix is to use a {% if %} and 2 separate output statements, allowing them to be auto-escaped separately.

A ternary operator is considered safe by the Twig auto-escaping only when
both branches are safe. But this ternary was safe only in the ELSE branch,
causing it to be unsafe. This triggered a double-escaping of the value
(escaping the output of the dump). The fix is to use a {% if %} and 2 separate
output statements, allowing them to be auto-escaped separately.
@stof
Copy link
Member Author

stof commented Jan 24, 2017

Note that 3.1 is not affected, because profiler_dump is not safe there

@linaori
Copy link
Contributor

linaori commented Jan 24, 2017

Okay, I have to admit, I would not have guessed this was even possible 😆

@stof stof changed the base branch from master to 3.2 January 24, 2017 09:52
@nicolas-grekas nicolas-grekas added this to the 3.2 milestone Jan 24, 2017
@nicolas-grekas
Copy link
Member

Good catch, thanks @stof.

@nicolas-grekas nicolas-grekas merged commit bc1f084 into symfony:3.2 Jan 24, 2017
nicolas-grekas added a commit that referenced this pull request Jan 24, 2017
…iler (stof)

This PR was merged into the 3.2 branch.

Discussion
----------

Fix double escaping of the decision attributes in the profiler

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #21384
| License       | MIT
| Doc PR        | n/a

A ternary operator is considered safe by the Twig auto-escaping only when both branches are safe. But this ternary was safe only in the ELSE branch, causing it to be unsafe. This triggered a double-escaping of the value (escaping the output of the dump). The fix is to use a {% if %} and 2 separate output statements, allowing them to be auto-escaped separately.

Commits
-------

bc1f084 Fix double escaping of the decision attributes in the profiler
@stof stof deleted the fix_double_escaping branch January 24, 2017 10:25
@javiereguiluz
Copy link
Member

@stof super nice catch! Thanks for the fix and the explanation.

@fabpot fabpot mentioned this pull request Feb 6, 2017
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.

5 participants