Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatted (HTML) messages with markdown features are rendered incorrectly as markdown #350

Closed
tulir opened this issue Jul 12, 2019 · 4 comments
Labels
A-Event rendering A-Markdown O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist T-Defect Something isn't working: bugs, crashes, hangs and other reported problems

Comments

@tulir
Copy link
Contributor

tulir commented Jul 12, 2019

When the formatted_body field of a "format": "org.matrix.custom.html" message contains special markdown characters, they're rendered as markdown instead of as plain text. This could be an actual problem if you escape markdown characters in a message that contains other formatting

Exaggerated example

Expected rendering

riot web
riot android

Actual rendering

riot x

Event source

{
  "type": "m.room.message",
  "sender": "@tulir:maunium.net",
  "content": {
    "msgtype": "m.text",
    "body": "Blank message (or is it? 🤔)",
    "format": "org.matrix.custom.html",
    "formatted_body": "---\n> * # [`RiotX` renders this message ***completely incorrectly***](https://github.com/vector-im/riotX-android/issues/289#issuecomment-510894293)\n---"
  },
  "event_id": "$156295723912295JSonL:maunium.net",
  "origin_server_ts": 1562957239380,
  "unsigned": {
    "age": 52
  },
  "room_id": "!tTIucwUZLRtKnXeurb:matrix.org"
}
Non-exaggerated example

Expected rendering

riot web
riot android

Actual rendering

riot x

Event source

{
  "type": "m.room.message",
  "sender": "@tulir:maunium.net",
  "content": {
    "msgtype": "m.text",
    "format": "org.matrix.custom.html",
    "body": "*less exaggerated example*: \\*\\*stars!**",
    "formatted_body": "<em>less exaggerated example</em>: **stars!**"
  },
  "event_id": "$156295796112315whymM:maunium.net",
  "origin_server_ts": 1562957961390,
  "unsigned": {
    "age": 170
  },
  "room_id": "!jhpZBTbckszblMYjMK:matrix.org"
}
Real-life example

matrix:room/riotx:matrix.org/event/$15630377604255dZoDF:hacklab.fi

This one was a reply sent from RiotX, which had indentation in the fallback format for some reason. The indentation of course turned into a code block because that's what a markdown parser does.

This specific example could be fixed by

  • fixing whatever caused the indentation, or
  • adding reply rendering to RiotX,

but of course neither of those is a proper fix to this issue.

Expected rendering

riot web
riot android

Actual rendering

riot x

Event source

{
  "content": {
    "body": "><@marmulak:converser.eu> Does the \"black\" theme work for reducing power consumption on oled displays?\n\nYes, the dark theme will reduce power consumption and the black theme will reduce it a bit more",
    "format": "org.matrix.custom.html",
    "formatted_body": "<mx-reply>\n               <blockquote>\n                   <a href=\"https://matrix.to/#/!tTIucwUZLRtKnXeurb:matrix.org/$1563036634937vaAEg:converser.eu\">In reply to</a>\n                   <a href=\"https://matrix.to/#/@marmulak:converser.eu\">@marmulak:converser.eu</a>\n                   <br />\n                   <p>Does the &quot;black&quot; theme work for reducing power consumption on oled displays?</p>\n\n               </blockquote>\n           </mx-reply>\n           Yes, the dark theme will reduce power consumption and the black theme will reduce it a bit more",
    "m.relates_to": {
      "m.in_reply_to": {
        "event_id": "$1563036634937vaAEg:converser.eu"
      }
    },
    "msgtype": "m.text"
  },
  "event_id": "$15630377604255dZoDF:hacklab.fi",
  "origin_server_ts": 1563037760897,
  "sender": "@vurpo:hacklab.fi",
  "type": "m.room.message",
  "unsigned": {
    "age": 630
  },
  "room_id": "!tTIucwUZLRtKnXeurb:matrix.org"
}
@bmarty
Copy link
Member

bmarty commented Sep 2, 2020

I reopen the issue, we will close it once when we can confirm that we do not reproduce it

@bmarty bmarty reopened this Sep 2, 2020
@jwh
Copy link

jwh commented Nov 12, 2021

\/\/\/\/

@bmarty bmarty added A-Markdown O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist T-Defect Something isn't working: bugs, crashes, hangs and other reported problems labels Nov 30, 2021
@bmarty bmarty removed this from the Stabilization2 milestone Nov 30, 2021
@cloudrac3r
Copy link
Contributor

I reopen the issue, we will close it once when we can confirm that we do not reproduce it

This really is fixed by #6357 and won't be reproduced anymore.

@bmarty
Copy link
Member

bmarty commented Jul 4, 2022

@cloudrac3r OK, thanks!
#6357 is included in Element Android 1.4.26.

@bmarty bmarty closed this as completed Jul 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Event rendering A-Markdown O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist T-Defect Something isn't working: bugs, crashes, hangs and other reported problems
Projects
None yet
Development

No branches or pull requests

4 participants