-
Notifications
You must be signed in to change notification settings - Fork 81
Strip shortcodes from the excerpt #1730
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
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.
Pull Request Overview
This PR aims to improve the excerpt handling by removing shortcodes to avoid potential abuse in the summary.
- Added a call to remove shortcodes from the content in the generate_post_summary function.
Comments suppressed due to low confidence (1)
includes/functions.php:1215
- [nitpick] Consider evaluating the order of content sanitization. Removing shortcodes before stripping all HTML tags might result in a cleaner excerpt if shortcode patterns could interfere with tag removal.
$content = \strip_shortcodes( $content );
….com/Automattic/wordpress-activitypub into update/strip-shortcodes-from-excerpt
This feels like a good change to add a unit test for? |
The thing is, that this is not the normal behaviour... must be some plugin that adds the shortcodes directly to the excerpt... |
But sure, will add some tests... |
@obenland I optimized the code a bit and added tests for all known cases. |
Would you mind updating the "Proposed Changes" list in the PR description with your changes? It looks like existing excerpts no longer short-circuit the function but now get processed fully, is that correct? |
yes, because that bypassed all the following sanitization |
@obenland done. |
My assumption would be that Core's sanitization for excerpts is enough—is it not? If not, what's missing?
What's the change in that optimization? |
This has some history: Sadly other plugins are doing too much weird things with the excerpt, so that is was needed. Here is some background: https://github.com/Automattic/wordpress-activitypub/issues?q=is%3Aissue%20excerpt
I changed it to a more descriptive one... I am sorry for the confusion. |
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.
Thank you!
This PR removes the shortcodes from the excerpt, because it seems to be possible to sneak them into the summary... shomehow...
Fixes https://c.im/@michael_martinez/114576417875641281
Update: While working on the unit-tests I found some glitches that bypassed the sanitization. This PR will also fix that issue.
Proposed changes:
remove_shortcode
and the other checksOther information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Improved excerpt handling and improved sanitization of summaries.