Repository navigation
fix(discord): prevent accidental mentions inside unfinished code - #129338
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 9:58 AM ET / 13:58 UTC. ClawSweeper reviewWhat this changesThe PR updates Discord known-mention rewriting so unfinished unescaped inline code protects the remaining text, while escaped backticks still allow later intended mentions to be converted. Merge readinessNo blocking correctness finding: the prior escaped-backtick concern is addressed. Keep this maintainer-associated PR open until its exact-head checks complete. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherDiscord outbound text is normalized before bot REST or persona-webhook delivery. This rewrite step converts cached handles into native Discord mentions while preserving Markdown code as literal text. flowchart LR
A[Outbound message text] --> B[Discord mention rewriter]
B --> C{Markdown code boundary}
C -->|code text| D[Preserve literal handle]
C -->|ordinary text| E[Convert cached handle]
D --> F[Bot REST or webhook payload]
E --> F
Before merge
Agent review detailsSecurityNone. PR surfaceSource -8, Tests +64. Total +56 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the narrow Discord-owner repair after exact-head checks are green, preserving literal unfinished code without suppressing mentions after escaped backticks. Do we have a high-confidence way to reproduce the issue? Yes, in source: current main skips an unmatched short backtick run and rewrites the remaining suffix; the focused owner and payload cases describe that path, though this read-only review did not execute them. Is this the best way to solve the issue? Yes. The repair stays in the Discord mention owner, and the canonical Markdown Core test independently supports its escaped-delimiter rule without importing core internals. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b0088684da37. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…nclaw#129338) * fix(discord): protect mentions inside unfinished inline code * fix(discord): respect escaped inline-code delimiters
What Problem This Solves
Discord rewrites a harmless name inside unfinished inline Markdown code into a real native user mention, generating an unintended notification through both ordinary bot messages and persona webhooks.
Why This Change Was Made
The Discord mention owner's private Markdown scanner skipped unmatched one- and two-backtick openers, while the canonical Markdown code-span owner already treats those spans as protected through the end of the message. The scanner now locates the first genuine unescaped code delimiter, honors odd/even preceding backslashes, and protects real unfinished code through the end of the message. Simplifying the owner removes eight production lines overall.
User Impact
Messages such as
Run \notify @Alice` remain literal unfinished code instead of unexpectedly pinging Alice. Escaped literal backticks do not suppress later legitimate mentions; odd/even backslash parity, balanced inline code, fenced code, ordinary intentional mentions, bot delivery, and persona webhooks keep their existing behavior.Evidence
node scripts/run-vitest.mjs extensions/discord/src/mentions.test.ts extensions/discord/src/send.sends-basic-channel-messages.test.ts extensions/discord/src/send.webhook.proxy.test.tspassed all 123 tests.