Fix rendering empty/malformed messages

This commit is contained in:
Tulir Asokan
2022-04-19 12:01:56 +03:00
parent 1e6174f828
commit 030c0c6ec5
2 changed files with 26 additions and 11 deletions

View File

@ -495,13 +495,18 @@ func Parse(prefs *config.UserPreferences, room *rooms.Room, content *event.Messa
parser := htmlParser{room: room, prefs: prefs, evt: evt}
root := parser.Parse(htmlData)
beRoot := root.(*ContainerEntity)
beRoot.Block = false
if len(beRoot.Children) > 0 {
beChild, ok := beRoot.Children[0].(*ContainerEntity)
if ok && beChild.Tag == "p" {
// Hacky fix for m.emote
beChild.Block = false
if root == nil {
return nil
}
beRoot, ok := root.(*ContainerEntity)
if ok {
beRoot.Block = false
if len(beRoot.Children) > 0 {
beChild, ok := beRoot.Children[0].(*ContainerEntity)
if ok && beChild.Tag == "p" {
// Hacky fix for m.emote
beChild.Block = false
}
}
}