bug: editing a multi-line message saves literal \n instead of line breaks

Offen Anfängerfreundlich
#1,430 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@arshil42 arbeitet bereits daran.

Seit 17.11.2026.

Bewertung

Schwierigkeit
1/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
92/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
javascript, react
Bereich
frontend

Rechercherichtung

Beginne in packages/react/src/views/ChatInput/ChatInput.js bei handleEditMessage und vergleiche den Bearbeitungspfad damit, wie neue Nachrichten gesendet werden. Entferne die Ersetzung des Zeilenumbruchs vor dem Aufruf von updateMessage und überprüfe anschließend, ob beim Bearbeiten einer Nachricht mit mehreren Zeilen die Zeilenumbrüche erhalten bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Description:

Editing a message that has more than one line saves it with a literal \n in place of each line break, so the edited message shows as a single line like line one\nline two.

handleEditMessage in packages/react/src/views/ChatInput/ChatInput.js still replaces every newline with backslash + n before calling updateMessage:

const res = await RCInstance.updateMessage(
  editMessageId,
  message.replace(/\n/g, '\\n')
);

That replacement was needed when updateMessage built its JSON body by hand ("text" : "${text}"). Since #1072, the body is built with JSON.stringify, which escapes the newline itself. The text is now escaped twice, and Rocket.Chat stores the backslash and the n as typed characters. Sending a new message does not do this replacement, which is why line breaks work there.

Steps to reproduce:
  1. Send a message with two lines (Shift + Enter between them).
  2. Edit the message, keeping two lines, and press Enter to save.
Expected behavior:

The edited message keeps its two lines, like a newly sent message.

Actual behavior:

The edited message is shown on one line as line one\nline two. The request body is {"roomId":"…","msgId":"…","text":"line one\\nline two"}, so the server receives a backslash followed by n, not a line break.

I'd like to send a fix that passes the message to updateMessage unchanged.

Vorherrschende Sprache
JavaScript
Sterne
170
Forks
397
Ø Merge
8 T. 20 Std.
Gemergte PRs (30 T.)
6

Entwicklungsumgebung

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus RocketChat/EmbeddedChat

Alle Issues in RocketChat/EmbeddedChat

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.