check that formattedBody exists before rendering a message as HTML

In case people send HTML messages without HTML, which they do for some reason.
This commit is contained in:
Henry Hiles 2026-10-26 23:54:28 -04:00
commit 285e6ad76a
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -73,11 +73,11 @@ class const MessageRenderer(
) => Column( ) => Column(
crossAxisAlignment: .start, crossAxisAlignment: .start,
children: [ children: [
format == .html && !textOnly format == .html && formattedBody != null && !textOnly
? Html( ? Html(
roomId: event.roomId, roomId: event.roomId,
textStyle: textStyle, textStyle: textStyle,
formattedBody!.replaceAllMapped( formattedBody.replaceAllMapped(
RegExp( RegExp(
r"(<a\b[^>]*>.*?<\/a>)|(\bhttps?:\/\/[^\s<]+)", r"(<a\b[^>]*>.*?<\/a>)|(\bhttps?:\/\/[^\s<]+)",
caseSensitive: false, caseSensitive: false,