WordPress / WordPress/WordPress-Coding-Standards

Downgrade unslash error to warning

Open
#838 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Focus: Security
Dominant language
PHP
Stars
2.8k
Forks
521
Avg merge
5d 20h
Merged PRs (30d)
1

Description

I believe the unslash error should be downgraded to a warning.

Quite often the expected value is known to the programmer and is a value which will never be slashed in the first place. Think: ?nr=5&type=post. If the value is slashed where no slashes are expected, it will automatically be an invalid value.
I know we can whitelist, but that litters the code with WPCS related comments, while IMHO, whitelist comments should only be used for exceptions.

For that matter, AFAIK, a nonce will never be a value which will be slashed, so unslashing shouldn't be required. If there are slashes in the received nonce, it will automatically be an invalid nonce value.

Opinions ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin by locating the PHP_CodeSniffer sniff in WordPress Coding Standards that reports unslash errors. Review how the existing whitelist behavior handles query values and nonces, then define and verify the change so these cases produce warnings rather than errors without requiring whitelist comments.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.