RocketChat / RocketChat/Rocket.Chat

Rocket.Chat improperly parses a diff with Markdown code in it

Open
#10,470 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description:

To reproduce the issue, paste the following text in a Rocket.Chat message:

``` diff
martin.mein-iserv.de ~ # diff -u test.txt test2.txt 
--- test.txt    2018-04-16 16:16:44.009313579 +0200
+++ test2.txt   2018-04-16 16:16:58.970366447 +0200
@@ -1 +1,7 @@
 This is a test.
+
+```
+some markdown code
+```
+
+This is another test line.
```

Normal Markdown parsers would display the result like this:

martin.mein-iserv.de ~ # diff -u test.txt test2.txt 
--- test.txt    2018-04-16 16:16:44.009313579 +0200
+++ test2.txt   2018-04-16 16:16:58.970366447 +0200
@@ -1 +1,7 @@
 This is a test.
+
+```
+some markdown code
+```
+
+This is another test line.

Rocket.Chat instead displays it like this:

martin.mein-iserv.de ~ # diff -u test.txt test2.txt 
--- test.txt    2018-04-16 16:16:44.009313579 +0200
+++ test2.txt   2018-04-16 16:16:58.970366447 +0200
@@ -1 +1,7 @@
 This is a test.
+
+

+some markdown code
+


+
+This is another test line.

Apparently it interprets the ``` in the diff as Markdown, which it shouldn't.

Server Setup Information:
  • Version of Rocket.Chat Server: 0.60.3
  • Operating System: Debian stretch
  • Deployment Method(snap/docker/tar/etc): tar
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Disabled
  • Node Version: v8.9.3
  • mongoDB Version: mongodb-org 3.2.17

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

Reproduce the issue by sending the supplied diff as a Rocket.Chat message and compare the rendered output with the expected Markdown rendering. Trace the message Markdown parsing and rendering path, focusing on how triple backticks inside a diff block are handled. Done means the embedded code fences remain part of the diff and the surrounding message renders correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
content, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.