Repository navigation
Add randomness for post selection #14018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
eafdb84
Add randomness for post selection
aaronjorbin 081f1eb
Fix phpstan suggestion
aaronjorbin 22e3af4
Apply batched suggestions from code review
aaronjorbin 9859a82
Updates based on code review
aaronjorbin ec32146
Apply batched suggestions from code review
aaronjorbin 93353e2
Add additional see comments
aaronjorbin d99d97d
Rename 'random_base' option to 'wp_random_base'
aaronjorbin 6dbde22
Merge branch 'trunk' into trac/64498
aaronjorbin c6f475f
Add `wp_random_base` option to schema.
peterwilsoncc 25b1b6c
Merge branch 'trunk' into trac/64498
peterwilsoncc fbc09a5
Fix assertion I broke: option is populated but empty.
peterwilsoncc 316e42b
Fix PHPStan `return.type` error in `WP_Rewrite::random_rewrite_rules()`
westonruter 18c3d95
Remove unused $post_ids variable
westonruter 619733d
Apply batched suggestions from code review
aaronjorbin 0c4279c
Remove wp_random_content_headers
aaronjorbin f9bf7e8
Fix PHPstan level 10 issues
aaronjorbin ff947e4
Enhance randomable post type functionality and tests
aaronjorbin 11c87e2
Merge branch 'trunk' into trac/64498
aaronjorbin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We aren't using wp_unslash for either the tag_base or the category_base. Is there a reason you think it's necessary here?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly as a correctness issue. All such input vars get slashed by WordPress, so they should be unslashed when read out.
Also, WPCS will flag such input superglobals as a
MissingUnslasherror that are accessed without slashing: https://github.com/WordPress/WordPress-Coding-Standards/blob/510f4f678ac00b65c162aa0ad57d4768940a0409/WordPress/Sniffs/Security/ValidatedSanitizedInputSniff.php#L224So all getters of these globals should be unslashed to prevent other devs from seeing it as a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WordPress.Security.ValidatedSanitizedInputisn't currently in the core ruleset and I think that is a separate conversation. I think consistency within core is more important and this builds off the rest of the file.The chain for this getting unslashed is
set_random_base()→update_option()→sanitize_option( 'wp_random_base' )→sanitize_url()→esc_url()which has an allow list that doesn't include backslashes.