Skip to content

Commit 0aebe1f

Browse files
committed
Security/Mustache: prevent false positive on partial text
Includes test.
1 parent 95305d3 commit 0aebe1f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

WordPressVIPMinimum/Sniffs/Security/MustacheSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function process_token( $stackPtr ) {
7171
}
7272
}
7373

74-
if ( strpos( $this->tokens[ $stackPtr ]['content'], 'SafeString' ) !== false ) {
74+
if ( strpos( $this->tokens[ $stackPtr ]['content'], '.SafeString' ) !== false ) {
7575
// Handlebars.js Handlebars.SafeString does not get escaped.
7676
$message = 'Found Handlebars.SafeString call which does not get escaped.';
7777
$this->phpcsFile->addWarning( $message, $stackPtr, 'SafeString' );

WordPressVIPMinimum/Tests/Security/MustacheUnitTest.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ $m = '%>=}} {{=<%'; // Incorrect order, not a delimiter change.
4949

5050
// Correctly recognize mid-line delimiter change.
5151
$m = '{{default_tags}} {{=<% %>=}} <% erb_style_tags %> <%={{ }}=%> {{ default_tags_again }}'; // NOK: delimiter change.
52+
53+
// Prevent false positives on SafeString being a partial name.
54+
echo 'MySafeString';

0 commit comments

Comments
 (0)