Skip to content

Commit ec41b77

Browse files
committed
Support multiple attributes as discussed during PR review
1 parent bf27bc6 commit ec41b77

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

WordPress/Sniffs/Security/EscapeOutputSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public function process_token( $stackPtr ) {
235235
}
236236

237237
// Skip over attribute declarations when searching for the open parenthesis.
238-
if ( \T_ATTRIBUTE === $this->tokens[ $next_relevant ]['code'] ) {
238+
while ( \T_ATTRIBUTE === $this->tokens[ $next_relevant ]['code'] ) {
239239
if ( isset( $this->tokens[ $next_relevant ]['attribute_closer'] ) === false ) {
240240
return;
241241
}

WordPress/Tests/Security/EscapeOutputUnitTest.1.inc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,4 +664,8 @@ echo '<input type="search" value="' . get_search_query( escaped: false ) . '">';
664664
throw new #[MyAttribute] readonly class( esc_html( $message ) ) extends Exception {}; // Good.
665665
throw new readonly class( $unescaped ) {}; // Bad.
666666
throw new #[MyAttribute] class( $unescaped ) extends Exception {}; // Bad.
667-
throw new #[MyAttribute] readonly class( $unescaped ) extends Exception {}; // Bad.
667+
throw new
668+
#[Attribute1]
669+
/* some comment */
670+
#[Attribute2('text', 10)]
671+
readonly class( $unescaped ) {}; // Bad.

WordPress/Tests/Security/EscapeOutputUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function getErrorList( $testFile = '' ) {
161161
657 => 1,
162162
665 => 1,
163163
666 => 1,
164-
667 => 1,
164+
671 => 1,
165165
);
166166

167167
case 'EscapeOutputUnitTest.6.inc':

0 commit comments

Comments
 (0)