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

Security/Mustache: prevent false positives on block editor templates #788

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WordPressVIPMinimum/Sniffs/Security/MustacheSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function register() {
*/
public function process_token( $stackPtr ) {

if ( strpos( $this->tokens[ $stackPtr ]['content'], '{{{' ) !== false || strpos( $this->tokens[ $stackPtr ]['content'], '}}}' ) !== false ) {
if ( strpos( $this->tokens[ $stackPtr ]['content'], '{{{' ) !== false && strpos( $this->tokens[ $stackPtr ]['content'], '}}}' ) !== false ) {
// Mustache unescaped output notation.
$message = 'Found Mustache unescaped output notation: "{{{}}}".';
$this->phpcsFile->addWarning( $message, $stackPtr, 'OutputNotation' );
Expand Down
5 changes: 4 additions & 1 deletion WordPressVIPMinimum/Tests/Security/MustacheUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ echo '<a href="{{href}}">{{&data}}</div></a>'; // NOK: data.

return new Handlebars.SafeString(result); // NOK: SafeString.
});
</script>
</script>

// Issue 541#issuecomment-1692323177: don't flag GB syntax.
<div class="wp-block-group"><!-- wp:heading {"textAlign":"center","style":{"spacing":{"margin":{"top":"0","right":"0","bottom":"var:preset|spacing|medium","left":"0"}}}} --><!-- OK. -->