-
Notifications
You must be signed in to change notification settings - Fork 0
[WRONG BRANCH] Fix: defuse bot-authored mentions in translated text after punctuation/Markdown #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1168,9 +1168,14 @@ describe("bot-owned control state", () => { | |||||||||||||||||||||||||||||||||||||
| assert.equal(decision.reason, "rate_limited_interval"); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| it("defuses mention-shaped tokens without rewriting emails or mid-token at-signs", () => { | ||||||||||||||||||||||||||||||||||||||
| const out = sanitizeTranslationBody("see @octocat and user@example.com and npm:@scope"); | ||||||||||||||||||||||||||||||||||||||
| it("defuses mention-shaped tokens at Markdown and punctuation boundaries", () => { | ||||||||||||||||||||||||||||||||||||||
| const out = sanitizeTranslationBody( | ||||||||||||||||||||||||||||||||||||||
| "see @octocat, comma,@team, [@user], >@org/team, user@example.com, npm:@scope", | ||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||
| assert.match(out, /@\u200boctocat/); | ||||||||||||||||||||||||||||||||||||||
| assert.match(out, /,@\u200bteam/); | ||||||||||||||||||||||||||||||||||||||
| assert.match(out, /\[@\u200buser\]/); | ||||||||||||||||||||||||||||||||||||||
| assert.match(out, />@\u200borg\/team/); | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1171
to
+1178
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Assert the preserved forms. The test input includes Add preservation assertions, and add a slash-bearing scoped-package case if bare npm scopes are part of the contract. Proposed test additions assert.match(out, /@\u200boctocat/);
assert.match(out, /,@\u200bteam/);
assert.match(out, /\[@\u200buser\]/);
assert.match(out, />@\u200borg\/team/);
+ assert.match(out, /user@example\.com/);
+ assert.match(out, /npm:`@scope/`);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| assert.ok(out.includes("user@example.com")); | ||||||||||||||||||||||||||||||||||||||
| assert.ok(out.includes("npm:@scope")); | ||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: luvs01/opencodex
Length of output: 253
🏁 Script executed:
Repository: luvs01/opencodex
Length of output: 39724
🌐 Web query:
GitHub username mention syntax colon immediately before@usernotification💡 Result:
No, a colon is not required before a GitHub
@mentionto trigger a notification [1][2]. The standard syntax for mentioning a user or team on GitHub is simply the @ symbol followed immediately by their username or team name (e.g.,@username) [1][3]. Placing a colon immediately before the @ symbol is not part of the standard@mentionsyntax and would not be interpreted as a user mention [1][4]. While colons are used in GitHub Flavored Markdown for other features—such as creating emoji (e.g.,:smile:)—they are not used for user or team mentions [4]. When you type @, GitHub provides an autocomplete list of users and teams that filters as you type [1][2]. Selecting a user or team from this list ensures the correct syntax is used to trigger a notification [1]. Notifications for@mentionsoccur when a user is mentioned in contexts such as issues, pull requests, and discussions, provided the user has read access to the repository [1][5][6].Citations:
Preserve bare scoped package names
At
.github/scripts/issue-translation.cjs:810-813, the regex rewrites bare@scope/packagetokens, althoughsanitizeTranslationBodystates that scopes must remain unchanged.@scope/packageand@org/teamhave the same lexical form. Add context-aware handling and tests for bare scopes,npm:@scope/package``, and@org/team.🤖 Prompt for AI Agents
Source: Path instructions