Description
When a slash command is typed in the message composer and the text contains a line break (Shift+Enter), the client drops everything after the first line break before the command is executed. Neither core slash commands nor Apps-Engine apps ever receive the remaining lines, and the user gets no feedback that part of their input was thrown away.
The cause is the parse regex in apps/meteor/client/lib/chats/flows/processSlashCommand.ts:
const parse = (msg: string): ... => {
const match = msg.match(/^\/([^\s]+)(.*)/);
...
};
(.*) is evaluated without the s (dotall) flag, so it stops matching at the first \n. The params string passed to commands.run therefore contains only the remainder of the first line.
The server side already handles multi-line parameters correctly: apps/meteor/lib/utils/parseParameters.ts splits on newlines for unquoted text and preserves newlines inside quoted strings. Invoking the same command through POST /api/v1/commands.run with multi-line params works as expected, which confirms the truncation is purely client-side.
Steps to reproduce
-
In the web client composer, type a core slash command such as /msg, press Shift+Enter, and continue the text on a second line, for example:
/msg @alice
don't forget the standup
-
Send the message.
Expected behavior
The full parameter text, including the line break, is passed to the command handler, matching what parseParameters on the server already supports. Alternatively, if multi-line slash commands are unsupported by design, the client should say so instead of silently discarding input.
Actual behavior
Only the text before the first line break is passed (@alice in the example), so the direct message body is lost with no warning. The same applies to any Apps-Engine app command that takes free text. Sending the identical params string through POST /api/v1/commands.run delivers the full multi-line text correctly.
Suggested fix
Add the dotall flag to the parse regex so params capture spans line breaks:
const match = msg.match(/^\/([^\s]+)(.*)/s);
Server-side handling needs no change; parseParameters already deals with newlines in both quoted and unquoted positions.
Server Setup Information
- Version of Rocket.Chat Server: 8.6.0 (reproduced; the regex is unchanged on current develop)
- Client: web client (the truncation is in the shared client flow, so desktop is affected equally)
- Apps-Engine version: 1.64.0
Additional context
Found while developing an Apps-Engine app whose slash command takes a free-text message. Users who put the message text on a new line after the command keyword lose the entire message body. An app can detect the resulting dangling parameters and hint at the limitation, but it cannot recover the discarded text, so this is not fixable at the app level.
Description
When a slash command is typed in the message composer and the text contains a line break (Shift+Enter), the client drops everything after the first line break before the command is executed. Neither core slash commands nor Apps-Engine apps ever receive the remaining lines, and the user gets no feedback that part of their input was thrown away.
The cause is the parse regex in
apps/meteor/client/lib/chats/flows/processSlashCommand.ts:(.*)is evaluated without thes(dotall) flag, so it stops matching at the first\n. Theparamsstring passed tocommands.runtherefore contains only the remainder of the first line.The server side already handles multi-line parameters correctly:
apps/meteor/lib/utils/parseParameters.tssplits on newlines for unquoted text and preserves newlines inside quoted strings. Invoking the same command throughPOST /api/v1/commands.runwith multi-lineparamsworks as expected, which confirms the truncation is purely client-side.Steps to reproduce
In the web client composer, type a core slash command such as
/msg, press Shift+Enter, and continue the text on a second line, for example:Send the message.
Expected behavior
The full parameter text, including the line break, is passed to the command handler, matching what
parseParameterson the server already supports. Alternatively, if multi-line slash commands are unsupported by design, the client should say so instead of silently discarding input.Actual behavior
Only the text before the first line break is passed (
@alicein the example), so the direct message body is lost with no warning. The same applies to any Apps-Engine app command that takes free text. Sending the identicalparamsstring throughPOST /api/v1/commands.rundelivers the full multi-line text correctly.Suggested fix
Add the dotall flag to the parse regex so params capture spans line breaks:
Server-side handling needs no change;
parseParametersalready deals with newlines in both quoted and unquoted positions.Server Setup Information
Additional context
Found while developing an Apps-Engine app whose slash command takes a free-text message. Users who put the message text on a new line after the command keyword lose the entire message body. An app can detect the resulting dangling parameters and hint at the limitation, but it cannot recover the discarded text, so this is not fixable at the app level.