Skip SVG text nodes in prompt-injection-redact#135
Merged
Conversation
Injection-shaped text inside an inline SVG's <title>/<desc>/<text> has no paragraph-level ancestor, so the rule's container walk escalated all the way to <article>/<section> and replaced the entire surrounding header. svg-text-strip already scrubs those nodes; skip them here so a buried-in-SVG match no longer wipes out the whole product header. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
<article>product header on the demo siteprompt-injection-redactmatched injection-shaped text inside the inline "Verified" SVG's<title>/<desc>/<text>and walked up looking for a paragraph-like ancestor. With nop/li/td/etc. between the SVG and the article, it escalated to<article>and replaced the whole header.svg-text-stripis the rule that handles SVG accessible/rendered text; skip those nodes inprompt-injection-redactso a buried-in-SVG match no longer collapses a surrounding section.Test plan
jest src/rules/__tests__/prompt-injection-redact.test.ts— 15/15 pass, including new regression case mirroring the demo SVG shapejest src/rules— 934/934 passbun run typecheckhttps://shield-dark-pattern-demo.vercel.app/product/p-headphones-1, confirm the product header (image, title, price, Add to Cart) renders normally and SVG title/desc/text are still scrubbed🤖 Generated with Claude Code