Skip to content

regression: slash command replies show HTML entities in names - #41983

Open
abhinavkrin wants to merge 1 commit into
release-8.8.0from
regression/i18n-escaping-slash-commands
Open

regression: slash command replies show HTML entities in names#41983
abhinavkrin wants to merge 1 commit into
release-8.8.0from
regression/i18n-escaping-slash-commands

Conversation

@abhinavkrin

@abhinavkrin abhinavkrin commented Aug 27, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

#41667 and #41736 replaced the i18next-sprintf-postprocessor (which never escaped) with i18next's native named interpolation (which escapes by default).

The server i18n instance never sets interpolation.escapeValue, so it falls back to the i18next default of true, while the client provider explicitly sets false:

Instance interpolation.escapeValue Escapes?
apps/meteor/server/lib/i18n.ts never set → i18next default true yes
apps/meteor/client/providers/TranslationProvider.tsx false no
packages/livechat/src/i18next.ts false no

The regression is therefore confined to server-side calls. Because these strings are delivered as ordinary chat message bodies, nothing decodes the entities and the user reads them literally:

/join #a&b
  before: The channel `#a&b` does not exist.
  after : The channel `#a&b` does not exist.

/kick @o'brien&co
  before: The username `o'brien&co` doesn't exist.
  after : The username `o'brien&co` doesn't exist.

Scope

40 translation keys moved from %s to {{...}} across the two PRs, spanning 67 call sites. 33 are client-side and unaffected. Of the 34 server-side sites, 4 (SlackBridge) were already opted out in #41736 itself, leaving 23 call sites patched here with interpolation: { escapeValue: false }.

This is deliberately scoped to sites whose behaviour actually changed. A global escapeValue: false on the server instance would be the tidier fix, but it is a workspace-wide policy change and does not belong on a release branch — see Further comments.

Escaping is not load bearing at any patched site

  • 21 sites broadcast via notify.ephemeralMessage. listeners.module.ts parses the string into a message-parser AST which gazzodown renders as React elements (PlainSpan emits {text}), so React escapes it. No dangerouslySetInnerHTML anywhere on that path.
  • 1 site (exportRoomMessagesToFile, the wm case) flows into exportMessageObject, which already calls escapeHTML() at the sink. That control was added by fix: escape HTML in exported data #40802 and is untouched here; at the time it landed Welcome still used %s and was not escaped by i18n, so this restores exactly the input it was written to receive. The site had been double escaping only since chore: replace positional translation parameters with named interpolation #41736.
  • 8 help sites interpolate hardcoded keyboard shortcuts such as Shift (or Ctrl) + ESC, which contain no HTML-special characters. They are a no-op either way and are included only so the rule stays uniform and greppable.

I also confirmed the two client call sites that do reach dangerouslySetInnerHTML (UrlChangeModal.tsx, OAuthGroupPage.tsx) both wrap in DOMPurify.sanitize(), and are on the client instance where escapeValue was already false before and after the migration. Untouched, unaffected.

Verification

Rendered every patched key through the real pre-migration stack (i18next + i18next-sprintf-postprocessor) and the post-patch stack, across values including a&b, o'brien&co, <b>x</b> and a"b:

fixed output == pre-migration sprintf output:  72 pass, 0 fail
cases that were broken before the patch:       60

tsc --noEmit --skipLibCheck exits clean, prettier passes, eslint reports 0 errors on the changed files.

Issue(s)

Closes: CORE-2645

Steps to test or reproduce

No admin configuration change is required:

  1. Open any channel.
  2. Run /join #a&b (any non-existent name containing &, <, >, " or ').
  3. Before: the ephemeral reply reads The channel `#a&amp;b` does not exist. After: The channel `#a&b` does not exist.

For the case reported in CORE-2645, which needs a widened validation setting:

  1. Admin → Workspace → Settings → General → UTF8, set UTF8_Channel_Names_Validation to [0-9a-zA-Z&_.-]+ and save.
  2. Create a public channel named a&b.
  3. Run /create a&b in any room.
  4. Before: The channel `#a&amp;b` already exists. After: The channel `#a&b` already exists.

Further comments

No changeset. Both migration PRs are unreleased, so this is a regression fixed within the same cycle.

Why not a global escapeValue: false on the server instance? It would fix all 23 at once and prevent recurrence, and I audited the blast radius: only 65 of the 212 server-side i18n.t calls actually interpolate, and just one key genuinely depends on escaping (UserDataDownload_EmailBody, whose <a href="{{download_link}}"> receives Site_Url + a Random.id(), so admin-controlled only). That makes it a good change for develop, but it is a workspace-wide behaviour change and too broad for a release branch. Worth a follow-up ticket.

Three adjacent issues found while tracing this, all pre-existing and deliberately left alone:

  • i18n.cloneInstance({ interpolation: { escapeValue: false } }) silently ignores the override in i18next 23.4.9, making the opt-out at sendTranscript.ts:113 dead code. The per-call form used in this PR does work.
  • notifications/message/email.js runs escapeHTML() on userName/roomName before handing them to i18n, which escapes again, so offline notification emails render Tom &amp; Jerry for any real name containing &. The same shape exists in mention.module.ts and in the other 11 cases of the exportRoomMessagesToFile switch. Unlike the wm case, those keys already used {{...}} before both migration PRs, so they are not regressions from this cycle and a fix for them would need its own changeset.
  • help/server.ts reads settings.get('language') with a lowercase id; the setting is Language.

CORE-2645

PRs #41667 and #41736 replaced the sprintf postprocessor with i18next's
named interpolation. The server i18n instance never sets
`interpolation.escapeValue`, so it defaults to `true`, while the client
provider sets it to `false`. Values interpolated server-side are now HTML
escaped, and since these strings are delivered as chat message bodies the
entities are shown to the user verbatim, e.g. `/create a&b` replies with
"The channel `#a&amp;b` already exists."

Opt out of escaping at the 23 server call sites whose keys moved from `%s`
to named interpolation in those two PRs. This restores the pre-migration
output exactly and leaves every other server interpolation untouched.

Escaping is not load bearing at any of these sites:

- 21 go to `notify.ephemeralMessage`, which parses the string into a
  message-parser AST rendered by gazzodown as React elements, so React
  escapes the text and no raw HTML sink is involved.
- `exportRoomMessagesToFile` already escapes with `escapeHTML()` at the
  sink, added by #40802, which is unchanged here. That call site had been
  double escaping since #41736.
- The 8 `help` sites interpolate hardcoded keyboard shortcuts with no
  HTML-special characters, so they are a no-op either way and are included
  only to keep the rule uniform.

No changeset: both migration PRs are unreleased, so this is a regression
within the same cycle.

Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
@abhinavkrin
abhinavkrin requested a review from a team as a code owner August 27, 2026 22:22
@dionisio-bot

dionisio-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3bae6aa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1d776611-26dd-4ed4-9a56-f12ebd918b10

📥 Commits

Reviewing files that changed from the base of the PR and between 01d81c2 and 3bae6aa.

📒 Files selected for processing (16)
  • apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts
  • apps/meteor/server/meteor-methods/rooms/addUsersToRoom.ts
  • apps/meteor/server/slashcommands/archiveroom/server.ts
  • apps/meteor/server/slashcommands/ban/ban.ts
  • apps/meteor/server/slashcommands/ban/unban.ts
  • apps/meteor/server/slashcommands/create/server.ts
  • apps/meteor/server/slashcommands/help/server.ts
  • apps/meteor/server/slashcommands/hide/hide.ts
  • apps/meteor/server/slashcommands/invite/server.ts
  • apps/meteor/server/slashcommands/inviteall/server.ts
  • apps/meteor/server/slashcommands/join/server.ts
  • apps/meteor/server/slashcommands/kick/server.ts
  • apps/meteor/server/slashcommands/msg/server.ts
  • apps/meteor/server/slashcommands/mute/mute.ts
  • apps/meteor/server/slashcommands/mute/unmute.ts
  • apps/meteor/server/slashcommands/unarchiveroom/server.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (2)
The main Rocket.Chat Meteor application resides in `apps/meteor/`; place its application code there rather than in other monorepo areas.

📄 CodeRabbit inference engine (CLAUDE.md)

Files:

  • apps/meteor/server/slashcommands/kick/server.ts
  • apps/meteor/server/slashcommands/ban/unban.ts
  • apps/meteor/server/slashcommands/mute/mute.ts
  • apps/meteor/server/slashcommands/inviteall/server.ts
  • apps/meteor/server/slashcommands/msg/server.ts
  • apps/meteor/server/slashcommands/ban/ban.ts
  • apps/meteor/server/slashcommands/archiveroom/server.ts
  • apps/meteor/server/slashcommands/join/server.ts
  • apps/meteor/server/slashcommands/unarchiveroom/server.ts
  • apps/meteor/server/slashcommands/help/server.ts
  • apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts
  • apps/meteor/server/meteor-methods/rooms/addUsersToRoom.ts
  • apps/meteor/server/slashcommands/invite/server.ts
  • apps/meteor/server/slashcommands/mute/unmute.ts
  • apps/meteor/server/slashcommands/hide/hide.ts
  • apps/meteor/server/slashcommands/create/server.ts
Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

Files:

  • apps/meteor/server/slashcommands/kick/server.ts
  • apps/meteor/server/slashcommands/ban/unban.ts
  • apps/meteor/server/slashcommands/mute/mute.ts
  • apps/meteor/server/slashcommands/inviteall/server.ts
  • apps/meteor/server/slashcommands/msg/server.ts
  • apps/meteor/server/slashcommands/ban/ban.ts
  • apps/meteor/server/slashcommands/archiveroom/server.ts
  • apps/meteor/server/slashcommands/join/server.ts
  • apps/meteor/server/slashcommands/unarchiveroom/server.ts
  • apps/meteor/server/slashcommands/help/server.ts
  • apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts
  • apps/meteor/server/meteor-methods/rooms/addUsersToRoom.ts
  • apps/meteor/server/slashcommands/invite/server.ts
  • apps/meteor/server/slashcommands/mute/unmute.ts
  • apps/meteor/server/slashcommands/hide/hide.ts
  • apps/meteor/server/slashcommands/create/server.ts
🧠 Learnings (2)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/server/slashcommands/inviteall/server.ts
  • apps/meteor/server/slashcommands/unarchiveroom/server.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/server/slashcommands/inviteall/server.ts
  • apps/meteor/server/slashcommands/unarchiveroom/server.ts
🔇 Additional comments (16)
apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts (1)

151-151: LGTM!

apps/meteor/server/meteor-methods/rooms/addUsersToRoom.ts (1)

113-113: LGTM!

apps/meteor/server/slashcommands/invite/server.ts (1)

66-66: LGTM!

Also applies to: 87-87

apps/meteor/server/slashcommands/ban/ban.ts (1)

24-24: LGTM!

apps/meteor/server/slashcommands/ban/unban.ts (1)

24-24: LGTM!

apps/meteor/server/slashcommands/help/server.ts (1)

61-61: LGTM!

apps/meteor/server/slashcommands/kick/server.ts (1)

27-27: LGTM!

apps/meteor/server/slashcommands/msg/server.ts (1)

35-35: LGTM!

apps/meteor/server/slashcommands/archiveroom/server.ts (1)

44-44: LGTM!

Also applies to: 63-63, 75-75

apps/meteor/server/slashcommands/create/server.ts (1)

44-44: LGTM!

apps/meteor/server/slashcommands/hide/hide.ts (1)

48-48: LGTM!

Also applies to: 57-57

apps/meteor/server/slashcommands/inviteall/server.ts (1)

52-52: LGTM!

Also applies to: 87-87

apps/meteor/server/slashcommands/join/server.ts (1)

28-28: LGTM!

apps/meteor/server/slashcommands/unarchiveroom/server.ts (1)

43-43: LGTM!

Also applies to: 62-62, 74-74

apps/meteor/server/slashcommands/mute/mute.ts (1)

26-26: LGTM!

apps/meteor/server/slashcommands/mute/unmute.ts (1)

25-25: LGTM!


Walkthrough

The changes add interpolation: { escapeValue: false } to server-side i18n calls for exported messages, room-method notifications, slash-command messages, and help shortcut descriptions.

Changes

Server i18n interpolation

Layer / File(s) Summary
Export and room message translations
apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts, apps/meteor/server/meteor-methods/rooms/addUsersToRoom.ts
Welcome and already-in-room messages disable HTML escaping for interpolated values.
Room command translations
apps/meteor/server/slashcommands/{archiveroom,create,hide,invite,inviteall,join,unarchiveroom}/...
Room-related slash-command messages disable interpolation escaping for channel, room, and user values.
User and help command translations
apps/meteor/server/slashcommands/{ban,kick,msg,mute}/..., apps/meteor/server/slashcommands/help/server.ts
User-not-found messages and help shortcut descriptions disable interpolation escaping.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 3bae6

This localized server-side change restores literal names in slash-command and related replies without altering client behavior; no actionable merge-blocking risk remains after normal checks and review.

Suggested labels: type: bug

Suggested reviewers: sampaiodiego

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 16 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing HTML entities displayed in names within slash command replies.
  • Fix all pre-merge checks with AI

Warning

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 16 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/server/lib/dataExport/exportRoomMessagesToFile.ts

@hacktron-app hacktron-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files

Severity Count
HIGH 1
MEDIUM 1

View full scan results

Comment thread apps/meteor/server/slashcommands/inviteall/server.ts
Comment thread apps/meteor/server/slashcommands/archiveroom/server.ts

@KevLehman KevLehman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test would be nice but we can create a UI test on a later task

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.8.0@01d81c2). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##             release-8.8.0   #41983   +/-   ##
================================================
  Coverage                 ?   69.33%           
================================================
  Files                    ?     4254           
  Lines                    ?   168642           
  Branches                 ?    30066           
================================================
  Hits                     ?   116934           
  Misses                   ?    46526           
  Partials                 ?     5182           
Flag Coverage Δ
e2e 58.78% <ø> (?)
e2e-api 46.14% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants