RocketChat / RocketChat/Rocket.Chat

Web client silently discards slash command text after the first line break before it reaches the command handler

Open Beginner friendly
#41,324 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

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
  1. 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
    
  2. 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/meteor/client/lib/chats/flows/processSlashCommand.ts and inspect the parse regex and the params passed to commands.run. Reproduce a slash command with text after a Shift+Enter line break, then verify that the complete multi-line parameter reaches the command handler and remains consistent with apps/meteor/lib/utils/parseParameters.ts.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.