@@ -82,8 +82,8 @@ public function process_token( $stackPtr ) {
8282
8383 $ data = [ $ function_name ];
8484
85- if ( $ function_name !== 'esc_url ' && $ this ->is_href_or_src ( $ this ->tokens [ $ html ]['content ' ] ) ) {
86- $ message = 'Wrong escaping function. href and src attributes should be escaped by `esc_url()`, not by `%s()`. ' ;
85+ if ( $ function_name !== 'esc_url ' && $ this ->attr_expects_url ( $ this ->tokens [ $ html ]['content ' ] ) ) {
86+ $ message = 'Wrong escaping function. href, src, and action attributes should be escaped by `esc_url()`, not by `%s()`. ' ;
8787 $ this ->phpcsFile ->addError ( $ message , $ stackPtr , 'hrefSrcEscUrl ' , $ data );
8888 return ;
8989 }
@@ -95,32 +95,32 @@ public function process_token( $stackPtr ) {
9595 }
9696
9797 /**
98- * Tests whether provided string ends with open src or href attribute .
98+ * Tests whether provided string ends with open attribute which expects a URL value .
9999 *
100- * @param string $content Haystack in which we look for an open src or href attribute .
100+ * @param string $content Haystack in which we look for an open attribute which exects a URL value .
101101 *
102- * @return bool True if string ends with open src or href attribute .
102+ * @return bool True if string ends with open attribute which exects a URL value .
103103 */
104- public function is_href_or_src ( $ content ) {
105- $ is_href_or_src = false ;
106- foreach ( [ 'href ' , 'src ' , 'url ' ] as $ attr ) {
104+ public function attr_expects_url ( $ content ) {
105+ $ attr_expects_url = false ;
106+ foreach ( [ 'href ' , 'src ' , 'url ' , ' action ' ] as $ attr ) {
107107 foreach ( [
108108 '=" ' ,
109109 "=' " ,
110110 '= \'" ' , // The tokenizer does some fun stuff when it comes to mixing double and single quotes.
111111 '=" \'' , // The tokenizer does some fun stuff when it comes to mixing double and single quotes.
112112 ] as $ ending ) {
113113 if ( $ this ->endswith ( $ content , $ attr . $ ending ) === true ) {
114- $ is_href_or_src = true ;
114+ $ attr_expects_url = true ;
115115 break ;
116116 }
117117 }
118118 }
119- return $ is_href_or_src ;
119+ return $ attr_expects_url ;
120120 }
121121
122122 /**
123- * Tests, whether provided string ends with open HMTL attribute.
123+ * Tests whether provided string ends with open HMTL attribute.
124124 *
125125 * @param string $content Haystack in which we look for open HTML attribute.
126126 *
0 commit comments