Keep WordPress shortcodes out of derived excerpts - #211
Merged
Conversation
A crossword post's whole body is a single [puzzleme ...] shortcode. The excerpt is derived by stripping HTML tags, which leaves brackets alone, so the derived excerpt was the shortcode source -- basepath, embed ids, attribution markup and all -- and the public site printed it under the headline on the Comics & Puzzles listing. Drop shortcodes before stripping tags, since attribute values carry HTML of their own (the puzzleme attribution is a link) that would otherwise be torn out from inside the brackets first. Two shapes are matched, both narrow enough to leave editorial brackets like "[sic]" and "[Editor's note]" alone: the shortcodes this corpus actually carries, named explicitly, and any bracketed token carrying attributes. This only governs excerpts derived from here on; rows already storing a shortcode excerpt are cleared separately, and Scalene strips on render. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A crossword post's whole body is a single
[puzzleme ...]shortcode.deriveExcerptstrips HTML tags, which leaves brackets alone, so the derived excerpt was the shortcode source — basepath, embed ids, attribution markup and all — and the public site printed it under the headline on the Comics & Puzzles listing:Shortcodes are now dropped before tags are stripped, since attribute values carry HTML of their own (the puzzleme attribution is a link) that would otherwise be torn out from inside the brackets first. Two shapes match, both narrow enough to leave editorial brackets like
[sic]and[Editor's note]alone:puzzleme,caption,gallery,embed,playlist,audio,video);Scope: this governs excerpts derived from here on. Rows that already store a shortcode excerpt are cleared directly, and DrexelTriangle/Scalene#77 strips on render so nothing else in the corpus can leak the same way.
Tests: four
deriveExcerptcases for the shortcode shapes plus one asserting editorial brackets survive.🤖 Generated with Claude Code