Repository navigation
fix(sections-editor): tighten Mustache template regex sanitization - #7428
Merged
Merged
Conversation
Replace [^}]+ with .+? (non-greedy any character) for proper multi-character handling in triple/double brace delimiters. Addresses code-scanning alert #11 (incomplete multi-character sanitization) by using the correct non-greedy matching pattern for Mustache templates, improving robustness on edge cases.
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.
Summary
Addresses code-scanning alert #11 (incomplete multi-character sanitization) in the sections-editor array-item-display component. Replaced
[^}]+with.+?(non-greedy any character) for proper multi-character handling in Mustache triple/double brace delimiters.Why
The previous regex pattern
[^}]+had edge case issues with multi-character closing brace sequences. Non-greedy matching (.+?) is the correct approach for Mustache template parsing and is more robust against boundary cases.Test plan
bun run fmtpassesbunx oxlint apps/web/src/components/sections-editor/array-item-display.tspasses with no errors{{{key}}}(triple braces) and{{key}}(double braces) templatesDiff
-1 / +1 (1 line changed)
The change is behavior-preserving: both patterns match the same content between delimiters, but
.+?correctly handles edge cases with multi-character sequences by using non-greedy matching.Summary by cubic
Replaces the regex pattern sanitizing Mustache templates in the sections-editor array-item display, addressing a code-scanning alert about incomplete multi-character sanitization.
The change swaps
[^}]+for non-greedy.+?so matches stop at the first closing brace sequence, improving robustness on edge cases while keeping the behavior identical for normal{{{key}}}and{{key}}templates.Written for commit 1722150. Summary will update on new commits.