Repository navigation
Keep bound attributes escaped in @unblaze scopes of folded components - #243
Merged
Merged
Conversation
Contributor
Benchmark Result: Default
Median of 10 attempts (* = outlier, excluded from result), 5000 iterations x 10 rounds, 9.53s total To run a specific benchmark, comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The scenario
A bound attribute that
flux:inputpasses on to its error message is printed unescaped, so user input can break out of the attribute:With
$value = 'Use "work" email':The same happens to
avatar:*attributes onflux:select.optionin Flux Pro, e.g.:avatar:aria-label="$value".The problem
Folding puts every dynamic value in an
@unblazescope back as the raw expression, even values from$attributes, which Blade escapes.While folding, Blaze renders the component once with placeholders instead of dynamic values, then swaps the original expressions back in. In HTML it swaps in
{{ $value }}, which escapes. But an@unblazescope is written into the compiled view as PHP, and there it swaps in the raw expression:flux:with-fieldpasses theerror:*attributes from its$attributestoflux:errorthrough a scope:When
flux:inputis folded, that scope compiles to:In Blade,
$valuewould reachflux:erroralready escaped, but because folding swapped the placeholder for the raw expression, the escaping was lost.The solution
Folding now gives props and
$attributesseparate placeholders. For the input above, the component is rendered with:Inside PHP code, a bound
ATTRplaceholder is restored escaped, like Blade does it:So the scope from
flux:with-fieldnow compiles to:Props stay raw, and placeholders in HTML still become
{{ $value }}.Added Flux and Flux Pro tests that compare both cases above with Blade.
Related: #222.