Skip to content

False positive for ProperEscapingFunction.hrefSrcEscUrl when attribute with action in name is used #669

@kkmuffme

Description

@kkmuffme

Bug Description

The above sniff is extremely prone to false positives, as it just checks for action/src/href, but should be at least be more specific for action.

Minimal Code Snippet

<input data-action="<?php echo esc_attr( $my_var ); ?>">

or:
'https://demo.com?foo=bar&my-action='<?php echo esc_attr( $var ); ?>

Error Code

Wrong escaping function. href, src, and action attributes should be escaped by esc_url(), not by esc_attr().
WordPressVIPMinimum.Security.ProperEscapingFunction.hrefSrcEscUrl

Environment

Use php -v and composer show to get versions.

Question Answer
PHP version 7.4.14
PHP_CodeSniffer version 3.6.0
VIPCS version 2.3.0

Tested Against master branch?

  • I have verified the issue still exists in the master branch of VIPCS.
  • I have verified the issue still exists in the develop branch of VIPCS.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions