WordPress / WordPress/WordPress-Coding-Standards
Check for encoding values passed to add_query_arg()
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
This is something suitable both for WordPress-VIP and WordPress-Extra:
add_query_arg()is a really useful function, but it might not work as intended.
The values passed to it are not encoded meaning that passing$m_yurl = 'admin.php?action=delete&post_id=321'; $my_url = add_query_arg( 'my_arg', 'somevalue&post_id=123', $my_url );You would expect the url to be:
admin.php?action=delete&post_id=321&somevalue%26post_id%3D123But in fact it becomes:
admin.php?action=delete&post_id=321&somevalue&post_id=123Using
rawurlencode()on the values passed to it prevents this.
https://vip.wordpress.com/documentation/encode-values-passed-to-add_query_arg/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the add_query_arg() behavior described in the issue and the linked WordPress VIP encoding guidance. Identify the PHP_CodeSniffer rule and its existing tests that cover this function, then verify that values containing query delimiters are detected and that the documented encoding expectation is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100