element-android icon indicating copy to clipboard operation
element-android copied to clipboard

Special characters are escaped in headings when they shouldn't be

Open SethFalco opened this issue 3 years ago • 5 comments

Steps to reproduce

  1. Have a chat open
  2. Have the other party send one of the following messages if they're on Element, if not on Element then a message that produces the same source:
#
{
  "type": "m.room.message",
  "content": {
    "org.matrix.msc1767.message": [
      {
        "body": "# <(^-^<)",
        "mimetype": "text/plain"
      },
      {
        "body": "<h1>&lt;(^-^&lt;)</h1>\n",
        "mimetype": "text/html"
      }
    ],
    "body": "# <(^-^<)",
    "msgtype": "m.text",
    "format": "org.matrix.custom.html",
    "formatted_body": "<h1>&lt;(^-^&lt;)</h1>\n"
  }
}
/html <h1>&lt&semi;(^-^&lt&semi;)</h1>
{
  "type": "m.room.message",
  "content": {
    "org.matrix.msc1767.message": [
      {
        "body": "<h1>&lt;(^-^&lt;)</h1>",
        "mimetype": "text/plain"
      },
      {
        "body": "<h1>&lt;(^-^&lt;)</h1>",
        "mimetype": "text/html"
      }
    ],
    "body": "<h1>&lt;(^-^&lt;)</h1>",
    "msgtype": "m.text",
    "format": "org.matrix.custom.html",
    "formatted_body": "<h1>&lt;(^-^&lt;)</h1>"
  }
}

Outcome

What did you expect?

Android devices should unescape special characters first before rendering the heading. For example, on Element Desktop and on GitHub it'll look like this:

<(^-^<)

What happened instead?

The less-than (<) symbols aren't unescaped, so the &lt; from when the content was converted to HTML is used literally and the user actually sees this:

&lt;(^-^&lt;)

A screenshot from the Android device: image

Your phone model

Fairphone 4

Operating system version

Android

Application version and app store

No response

Homeserver

one.ems.host

Will you send logs?

No

Are you willing to provide a PR?

Yes

SethFalco avatar Jul 31 '22 20:07 SethFalco

I am not sure what you mean with "headings" but it happens in normal messages too.

Just send some text from Element Android with an ampersand in it. It will appear as &amp; when rendered in the timeline.

paulvt avatar Aug 01 '22 12:08 paulvt

I don't use Android, so I only know about the issue that was screenshotted and shared with me. Headings refers to using Markdown to create a heading.

# This is a Heading!

This is a Heading!

SethFalco avatar Aug 01 '22 12:08 SethFalco

Yeah, this happens in half my messages, too: Screenshot_20220803-160942_Element

effbiae avatar Aug 03 '22 10:08 effbiae

Duplicate of #6445

tulir avatar Aug 03 '22 11:08 tulir

Hmm, I'll make my wife check for updates and check this out again. If the bug is resolved, I'll close the issue.

SethFalco avatar Aug 03 '22 11:08 SethFalco

thanks for raising! this is indeed #6445 and was fixed as part of 1.4.28

ouchadam avatar Aug 18 '22 14:08 ouchadam