mautrix / whatsapp

A Matrix-WhatsApp puppeting bridge
https://maunium.net/go/mautrix-whatsapp
GNU Affero General Public License v3.0
1.29k stars 175 forks source link

Newline following link <a href=...> is removed on the WhatsApp side #604

Closed maltee1 closed 1 year ago

maltee1 commented 1 year ago

When sending a link, some matrix clients (such as element) will convert that to a html reference. I suppose WhatsApp doesn't render html tags, so they need to be removed before sending. The WhatsApp client then recognizes the link itself and makes it clickable for the user.

The problem is, if a link is followed by a newline, that newline will be removed along with the html tags, appending the first word on the new line to the link, which causes WhatsApp to include that word into the clickable link, making it invalid. This caused quite some confusion in one of my groups. Mautrix-signal, which is bridging part of the same group, does not have that issue.

tulir commented 1 year ago

Doesn't seem reproducible with just a newline

maltee1 commented 1 year ago

So apparently this happens when I send it from Nheko, not Element, with a single linebreak, which is rendered as a space. Element doesn't include the html tags. Sorry about the confusion. For clarification, this is what breaks:

"content": {
        "body": "https://dies.ist.ein/test\nDies ist ein test",
        "format": "org.matrix.custom.html",
        "formatted_body": "<a href=\"https://dies.ist.ein/test\">https://dies.ist.ein/test</a>\nDies ist ein test",
        "msgtype": "m.text"
    }
tulir commented 1 year ago

There's no line break in that HTML, so sounds like a Nheko bug (or feature if they're intentionally using markdown like that)

maltee1 commented 1 year ago

I just updated nheko, it's fixed now.