tulir / gomuks

A Matrix client written in Go.
https://maunium.net/go/gomuks
GNU Affero General Public License v3.0
1.37k stars 123 forks source link

Fix line breaks with URLs in plaintext only messages #399

Closed n-peugnet closed 2 years ago

n-peugnet commented 2 years ago

This fixes an incorrect rendering behaviour in the timeline and the plaintext mode, introduced by #388, for plain text only messages that combined URLs and newlines.

For example with events of this kind:

{
  "type": "m.room.message",
  "content": {
    "body": "Test message :\n\nhttps://alink.com/that/is/longer\nhttps://ashortlink.fr\n\nEnd of message",
    "msgtype": "m.text"
  }
}

This changes makes sure that there is always only one container and no empty text Entities in the HTML message.

Timeline Before 2022-11-01-180710_541x167_scrot

Timeline After 2022-11-01-180827_541x272_scrot

Plaintext Before 2022-11-01-180713_541x167_scrot

Plaintext After 2022-11-01-180831_541x272_scrot

I am sorry for not catching this bug earlier.

This time I tried to test a lot of edge cases and it behaved properly.