-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ProperEscapingFunction: Fix short tag detection
The tracking variable `$in_short_echo` was never reset when checking different files, meaning that the property would carry over and provide the wrong context to the next file. By adding logic to the `process_token()` method of the ProperEscapingFunctionSniff, we can reset the tracking variable at the start of each file by comparing the currently processing file to the last one stored in a static variable. Includes two unit test files, numbered in the order needed to trigger the bug if the fix wasn't present. Fixes #739.
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
8 changes: 8 additions & 0 deletions
8
WordPressVIPMinimum/Tests/Security/ProperEscapingFunctionUnitTest.2.inc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
/* | ||
* This is part one of a two-part test. It must be in a lower-numbered file | ||
* than part two, to trigger the bug in | ||
* https://github.com/Automattic/VIP-Coding-Standards/issues/739 | ||
*/ | ||
?> | ||
<?= esc_attr('short_tag') ?> |
11 changes: 11 additions & 0 deletions
11
WordPressVIPMinimum/Tests/Security/ProperEscapingFunctionUnitTest.3.inc
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/* | ||
* This is part two of a two-part test. It must be in a higher-numbered file | ||
* than part one, to trigger the bug in | ||
* https://github.com/Automattic/VIP-Coding-Standards/issues/739 | ||
*/ | ||
printf( | ||
'<div class="%1$s"><p>%2$s</p></div>', | ||
esc_attr($class), | ||
wp_kses_post($message) | ||
); |