element-hq / element-hq/element-android

Strange formatted message handling

Open
#1,375 2 comments 4 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
3.7k
Forks
917
Avg merge
8d 20h
Merged PRs (30d)
1

Description

riotX shows strange display behavior with formatted messages.

# Expected behavior:
if a message contains `"format":"org.matrix.custom.html" `and a `formatted_body` field, the contents of the `formatted_body` are displayed.
# Current behavior:
if the `body` field contains a code block in markdown, the body field is parsed as markdown and displayed instead of the formatted body(markdown parsing only if it is a `org.matrix.custom.html` message).

Furthermore, when the html body is used, the pre/code block is not properly formatted(see third example in the screenshots below).

screenshots:

Expected message display(riot desktop):
![2020-05-16-184925_456x240_scrot](https://user-images.githubusercontent.com/676264/82125389-3696df80-9795-11ea-9043-39a05be07087.png)

Riotx display:
![2020-05-16-185301_1074x388_scrot](https://user-images.githubusercontent.com/676264/82125483-bfae1680-9795-11ea-90eb-bbe3676894ed.png)

Message sources:
```
"content": {
"msgtype": "m.text",
"format": "org.matrix.custom.html",
"body": "```\ncode body 1",
"formatted_body": "

html body 1
"
},
```

```
"content": {
"msgtype": "m.text",
"format": "org.matrix.custom.html",
"body": "normal body 2",
"formatted_body": "

html body 2
"
},
```

```
"content": {
"body": "```\ncode body 3",
"msgtype": "m.text"
},
```
@tulir identified the source for the issue [here](https://github.com/vector-im/riotX-android/blob/5fa247a0c5c02e34ea2caf6b68e458b115eb21ce/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/MessageItemFactory.kt#L356)

Our troubleshooting discussion in the #riotx room can be found [here](https://matrix.to/#/!gGkYcJLTzcNrfERksd:matrix.org/$a2pBDO4VhlGZyxQyM2KJRGUeMC6aIk5PbYuwSyghwAI?via=matrix.org&via=privacytools.io&via=tchncs.de)

Tested version: 0.19.0 [40019000] (F-be9393fa)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.