Fix: prompt-injection-redact would re-hide a revealed container#161
Merged
Conversation
Same structural bug as #160 (disguised-ad-flag): the hidden element is an ancestor of the matched text node, so the reveal stamp lands on the container — not on anything `walkTextNodes` returns. The skip set only checked `isInsidePlaceholder` and `isConnected`, so a subsequent `apply` (rule disable→enable, or any future MutationObserver-driven re-scan) walked back up from the still-present injection text and re-wrapped the same container. Not yet user-visible because the rule has no watcher, but the fix is the same one-liner used in #160 — closer to apply rather than walk through three more bug reports if a watcher is wired in later. 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
Same structural bug as #160 (disguised-ad-flag): the hidden element is an ancestor of the matched text node (the nearest
p/li/blockquote/…/section), so the reveal stamp lands on the container — not on anythingwalkTextNodesreturns. The candidate-skip set only checkedisInsidePlaceholderandisConnected, so a subsequentapplywalked back up from the still-present injection text and re-wrapped the same container into a fresh placeholder.Not yet user-visible because
prompt-injection-redacthas noMutationObserver, so reveal never triggers an immediate re-scan. Two paths still hit it today:revealAllis a no-op for already-revealed placeholders), then toggles it back on.applyre-fires and re-hides their previously-revealed content.prompt-injection-redactever gets one, this becomes the same unrevealable-loop bug Fix: disguised-ad-flag re-hid the article a user just revealed #160 fixed.Fix is the one-liner from #160 —
closest([data-abs-revealed="prompt-injection-redact"])against the container before hiding.Audited every other reveal-capable rule while I was in here; this was the only twin. Other rules either pass the candidate directly to
replaceWithBlockPlaceholder(soREVEALED_ATTRlands on what they check), dedup via a per-ruleWeakSetof processed elements (countdown-timer-redact,irrelevant-sections-redact), or use inline text-node placeholders whose reveal mutation the watcher already filters out.Test plan
bun run test(1265 passed, 65 suites)bunx tsc --noEmitcleanbunx eslintclean on touched filesprompt-injection-redact.test.ts:🤖 Generated with Claude Code