-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Font Library: run wp_font_family post content sanitization using wp_insert_post_data filter #56172
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/experimental/fonts/font-library/class-wp-font-family-utils.php ❔ lib/experimental/fonts/font-library/class-wp-font-family.php ❔ lib/experimental/fonts/font-library/font-library.php |
…lowing the core example
…lowing the core example
617064c
to
498978a
Compare
Flaky tests detected in 770c5b5. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7213572544
|
lib/experimental/fonts/font-library/class-wp-font-family-utils.php
Outdated
Show resolved
Hide resolved
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.
Thanks for picking this up, @jffng! I've left a few comments, they're mainly around "should we add a check for this".
lib/experimental/fonts/font-library/class-wp-font-family-utils.php
Outdated
Show resolved
Hide resolved
….php Co-authored-by: Sarah Norris <1645628+mikachan@users.noreply.github.com>
@mikachan thanks for the feedback, I think I've addressed it all. |
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.
Nice, the changes look good to me!
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.
I have one more concern with this PR:
The wp_insert_post_data
filter is called every time a post of any type is created, updated, or deleted. I ran a search of the core codebase, and it's only used four times: https://github.com/search?q=repo%3AWordPress%2Fwordpress-develop+add_filter%28+%27wp_insert_post_data%27+&type=code
I'm wondering if this is an efficient way to go about sanitization, or is it overkill?
The reason to use |
…rdPress/gutenberg into fix/sanitize-font-family-post-content
After discussing it again with @jffng, we could close this PR. It was created on the belief that we could create posts of custom post types using the default endpoint, but that's not the case, Right now, I can't think of a way to create a Feel free to re-open if you can think of a way that a malicious user could create a wp_font_family bypassing the custom endpoint and sanitation. |
What?
This PR changes where and when data sanitization happens, running it right before it is inserted into the database using the
wp_insert_post_data
filter.Why?
This is done for security reasons, to ensure that we are not storing data that is unescaped.
The
wp_font_family
posts could theoretically be created outside of the context of the Font Library class, e.g. via manual insertion of a post, and currently we are only calling the sanitization method inside of the Font Library class.How?
Calling the sanitization function on
wp_font_family
type posts to filter the data before insertion into the database.Testing Instructions
Marking this as a draft because it requires #53273 to work as expected.