Skip to content

Commit a050233

Browse files
committed
Adding open attribute ending with url to the ProperEscapingFunction sniff.
Eg.: `<media:content url="`, `data-image-url="`
1 parent 8ec9fd5 commit a050233

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

WordPressVIPMinimum/Sniffs/VIP/ProperEscapingFunctionSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function process( File $phpcsFile, $stackPtr ) {
103103
*/
104104
public function is_href_or_src( $content ) {
105105
$is_href_or_src = false;
106-
foreach ( array( 'href', 'src' ) as $attr ) {
106+
foreach ( array( 'href', 'src', 'url' ) as $attr ) {
107107
foreach ( array(
108108
'="',
109109
"='",

WordPressVIPMinimum/Tests/VIP/ProperEscapingFunctionUnitTest.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ echo "<a title='" . esc_html( $some_var ) . "'></a>"; // NOK.
2525
<a href="<?php esc_url( $url );?>"></a> <!-- OK. -->
2626

2727
<a title="<?php esc_attr( $url );?>"></a> <!-- OK. -->
28+
29+
<?php
30+
31+
echo '<media:content url="' . esc_url( $post_image ) . '" medium="image">'; // OK.
32+
33+
echo '<media:content url="' . esc_attr( $post_image ) . '" medium="image">'; // NOK.
34+
35+
echo 'data-param-url="' . esc_url( $share_url ) . '"'; // OK.
36+
37+
echo 'data-param-url="' . esc_html( $share_url ) . '"'; // NOK.

WordPressVIPMinimum/Tests/VIP/ProperEscapingFunctionUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function getErrorList() {
2929
17 => 1,
3030
21 => 1,
3131
23 => 1,
32+
33 => 1,
33+
37 => 1,
3234
);
3335
}
3436

0 commit comments

Comments
 (0)