Exclude _wpnonce URLs in speculation rules #1143
Merged
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.
This is a sub-PR of #1142.
Fixes #1141
The URLPattern used to exclude URLs with
_wpnonceis/*\?*(^|&)_wpnonce=*. Take special note that the second*wildcard only matches chars in the query segment. Additionally, the^anchors the match to the beginning of thesearchsegment, and not to the beginning of the entire string. (Remember:URLPatternis not regex.) This means that only the_wpnoncequery 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=1234http://example.com/?_wpnonce=1234http://example.com/foo/?amp=1&_wpnonce=1234http://example.com/?amp=1&_wpnonce=1234http://example.com/foo/?_wpnonce=1234&=1http://example.com/?_wpnonce=1234&=1http://example.com/?my_wpnonce=1234_wpnonce)http://example.com/?p=1#?_wpnonce=1234http://example.com/_wpnonce=1234/