-
Notifications
You must be signed in to change notification settings - Fork 110
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
Exclude _wpnonce URLs in speculation rules #1143
Conversation
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.
LGTM!
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Nice thorough set of tests btw. Anyway we can add them to the plugin test suite so if someone in future isn't as robust as you, it's still covered? |
That's a good idea. I've opened #1144 to explore that. |
This is a sub-PR of #1142.
Fixes #1141
The URLPattern used to exclude URLs with
_wpnonce
is/*\?*(^|&)_wpnonce=*
. Take special note that the second*
wildcard only matches chars in the query segment. Additionally, the^
anchors the match to the beginning of thesearch
segment, and not to the beginning of the entire string. (Remember:URLPattern
is not regex.) This means that only the_wpnonce
query parameter will matched, whether it is the first query parameter or not. It also won't incorrectly matchother_wpnonce
.The following URLs were tested to be properly included and excluded:
http://example.com/foo/?_wpnonce=1234
http://example.com/?_wpnonce=1234
http://example.com/foo/?amp=1&_wpnonce=1234
http://example.com/?amp=1&_wpnonce=1234
http://example.com/foo/?_wpnonce=1234&=1
http://example.com/?_wpnonce=1234&=1
http://example.com/?my_wpnonce=1234
_wpnonce
)http://example.com/?p=1#?_wpnonce=1234
http://example.com/_wpnonce=1234/