-
Notifications
You must be signed in to change notification settings - Fork 211
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
Stop WP rewrite rules from matching files like wp-admin.css #1317
Conversation
It would be nice to get the quick fix in for @fatihbalsoy who reported the issue, but perhaps we can make a follow-up PR to further reduce the chances of false-positives. @bgrgicak, do we know more about the expected paths that prefix wp-admin, wp-content, and others that we could use to make this pattern not accidentally match similarly named directories in plugins and themes? |
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.
Good fix @brandonpayton! Let's merge and deploy the site.
Thanks for the fix! What you did makes sense, I just forgot to add the |
Would that also be a problem with a regular hosted WordPress? |
I tested it on a new multisite and it worked, so this was just Playground bug. |
I didn't mean the thing this PR fixed. I meant what @brandonpayton mentioned about plugins containing |
I think I was wrong about there being further possibility of false positives for plugins and themes. Both will already be under the /^\/(.*?)(\/wp-(content|admin|includes)\/.*)/g And the pattern has other aspects which should make it safer for nested directories:
I tested a bit with examples in the dev tools console, and it behaved well with paths like
|
What is this PR doing?
This PR fixes a bug in our WordPress rewrite rules where plugin files named things like "wp-admin.css" were having their preceding plugin-specific path removed.
This was reported in WP.org Slack (#playground-logs):
https://wordpress.slack.com/archives/C06Q5DCKZ3L/p1713585476733489
How is the problem addressed?
This PR tweaks the pattern to only apply to directories. This fixes the problem of matching files but still leaves open the possibility of false positives when plugins or themes contain directories named /wp-admin/, /wp-includes/, etc.
Testing Instructions
npm run dev
Without this fix, the appearence of the lefthand menu bar is obviously broken like: