Repository navigation
fix(discord): protect mention aliases in code fences - #90648
rohitjavvadi wants to merge 1 commit into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close: this source PR is superseded by the merged maintainer replacement that carried forward the same Discord mention-alias code-fence fix, credited the contributor, and is now present on current main and in the latest release. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close the superseded source branch, keep the merged replacement implementation, and handle any desired extra edge-case coverage as a new narrow follow-up. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close the superseded source branch, keep the merged replacement implementation, and handle any desired extra edge-case coverage as a new narrow follow-up. Do we have a high-confidence way to reproduce the issue? Yes. The original bug is source-reproducible from the old non-greedy regex and documented caller paths, and the PR body includes terminal proof against the helper; current main now contains the scanner fix. Is this the best way to solve the issue? Yes. The merged replacement is the best current solution because it fixes the owner-local Discord helper used by all affected send paths and avoids keeping a conflicting source branch open. Security review: Security review cleared: Security review cleared: the source PR changes only Discord mention parsing and focused tests, with no dependency, workflow, secret, package, or code-execution surface changes. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against d1b917120a47; fix evidence: release v2026.6.10, commit 6656c71c7a12. |
0d663a8 to
1064165
Compare
1064165 to
dc1a57d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10641656e9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
dc1a57d to
8912312
Compare
|
@clawsweeper re-review Addressed the same-line triple-backtick scanner finding in |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
8912312 to
8585709
Compare
|
@clawsweeper re-review Rebased this branch onto current Local checks after the rebase:
All passed. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Clownfish 🐠 reef update Thanks for the contribution. The source branch was not safely writable by Clownfish, so it opened a replacement PR and kept the credit trail visible. Replacement PR: #93662 fish notes: model gpt-5.5, reasoning medium; reviewed against 3204295. |
|
🦞✅ Reason: structured ClawSweeper close marker: close-required (sha=8585709cfa599086ce1208b799227dbcb98e0853) Closed:
|
Summary
Fixes #90643.
Discord mention alias rewriting now skips Markdown code spans with a local scanner instead of a non-greedy regex, so a triple-backtick literal inside a fenced code block no longer makes later in-fence
@handletext eligible for outbound mention rewriting.This keeps the existing Discord behavior where text after a closing fence marker can still be rewritten, while preventing the code body itself from producing an unintended
<@USER_ID>mention.Root Cause
rewriteDiscordKnownMentionspreviously used:/```[\s\S]*?```|`[^`\n]*`/gThat regex closes the skipped code segment on the first downstream triple-backtick sequence anywhere. In a block like this, the string literal was treated as the closing fence:
The remaining code-body line was then passed through mention alias rewriting and could become a real Discord targeted mention.
Real behavior proof
@handlethat is inside a backtick fenced code block when the code body contains a triple-backtick literal. Handles after the closing fence still rewrite.rewriteDiscordKnownMentionshelper used by Discord normal sends, structured sends, webhooks, and final-preview create/edit gating.node --import tsx --input-type=modulewith the script below, importingrewriteDiscordKnownMentionsand the Discord directory-cache helpers from this checkout.{"actual":"```js\nconst fence = \"```\";\n// do not ping @alice\n```\ntext <@123456789>"}.@aliceremains literal, while the@aliceafter the closing fence rewrites to<@123456789>.Command and terminal output:
Evidence after fix:
{ "actual": "```js\nconst fence = \"```\";\n// do not ping @alice\n```\ntext <@123456789>" }Follow-up proof for the same-line inline triple-backtick case:
Follow-up evidence after fix:
{ "actual": "inline ```@alice```\ntext <@123456789>" }Tests And Checks
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-activity.test.ts --reporter dot node scripts/run-vitest.mjs extensions/discord/src/mentions.test.ts --reporter dot pnpm exec oxfmt --check extensions/discord/src/mentions.ts extensions/discord/src/mentions.test.ts node scripts/run-oxlint.mjs extensions/discord/src/mentions.ts extensions/discord/src/mentions.test.ts pnpm tsgo:extensions git diff --checkResults:
pnpm tsgo:extensionspassedgit diff --checkpassedCompatibility And Risk
The change stays local to Discord mention rewriting and does not add plugin dependencies. It preserves existing simple inline-code/fence behavior and adds coverage for longer fence delimiters, inline spans with shorter backtick runs inside, and the fact that tilde runs are not Discord code fences.
Overlap: #90646 opened against the same issue while this local fix was being prepared.