From e9ec6993df0a3ed4629fde6105e6ce46dbfee1d1 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Sun, 27 Dec 2020 16:47:03 +0100 Subject: [PATCH] fix: Reply fallback sometimes being stripped incorrectly --- lib/components/html_message.dart | 5 ++++- lib/components/message_content.dart | 2 +- lib/components/reply_content.dart | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/components/html_message.dart b/lib/components/html_message.dart index 9139cf0b..3e3864a0 100644 --- a/lib/components/html_message.dart +++ b/lib/components/html_message.dart @@ -30,7 +30,10 @@ class HtmlMessage extends StatelessWidget { // We do *not* do this in an AST and just with simple regex here, as riot-web tends to create // miss-matching tags, and this way we actually correctly identify what we want to strip and, well, // strip it. - final renderHtml = html.replaceAll(RegExp('.*<\/mx-reply>'), ''); + final renderHtml = html.replaceAll( + RegExp('.*<\/mx-reply>', + caseSensitive: false, multiLine: false, dotAll: true), + ''); // there is no need to pre-validate the html, as we validate it while rendering diff --git a/lib/components/message_content.dart b/lib/components/message_content.dart index 0e11e043..08b6e5e8 100644 --- a/lib/components/message_content.dart +++ b/lib/components/message_content.dart @@ -95,7 +95,7 @@ class MessageContent extends StatelessWidget { if (AppConfig.renderHtml && !event.redacted && event.isRichMessage) { - String html = event.content['formatted_body']; + var html = event.formattedText; if (event.messageType == MessageTypes.Emote) { html = '* $html'; } diff --git a/lib/components/reply_content.dart b/lib/components/reply_content.dart index 9af5bdb1..36a9c638 100644 --- a/lib/components/reply_content.dart +++ b/lib/components/reply_content.dart @@ -34,16 +34,18 @@ class ReplyContent extends StatelessWidget { if (displayEvent.messageType == MessageTypes.Emote) { html = '* $html'; } + final fontSize = DefaultTextStyle.of(context).style.fontSize; replyBody = HtmlMessage( html: html, defaultTextStyle: TextStyle( color: lightText ? Colors.white : Theme.of(context).textTheme.bodyText2.color, - fontSize: DefaultTextStyle.of(context).style.fontSize, + fontSize: fontSize, ), maxLines: 1, room: displayEvent.room, + emoteSize: fontSize * 1.5, ); } else { replyBody = Text(