[fractal] Message Widget: Do not render incomplete messages



commit 8bf85c11d7483d339b4e8b2325f1db64159e8190
Author: Maximiliano Sandoval R <msandova protonmail com>
Date:   Tue Dec 22 15:11:44 2020 +0100

    Message Widget: Do not render incomplete messages
    
    If a message contains raw html, the formatted body will contain a
    comment, and instead of showing an incomplete message, the plain text
    message is used.

 fractal-gtk/src/widgets/message.rs | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/fractal-gtk/src/widgets/message.rs b/fractal-gtk/src/widgets/message.rs
index 218906d0..319d7a24 100644
--- a/fractal-gtk/src/widgets/message.rs
+++ b/fractal-gtk/src/widgets/message.rs
@@ -523,6 +523,12 @@ fn build_room_msg(
 fn build_room_msg_body_html(container: &MessageBoxContainer, msg: &Message) -> anyhow::Result<gtk::Box> {
     let raw = msg.msg.formatted_body.clone().unwrap_or_default();
 
+    if raw.contains("<!-- raw HTML omitted -->") {
+        anyhow::bail!(
+            "Empty message omited: <!-- raw HTML omitted -->, using plain text instead."
+        );
+    }
+
     let blocks =
         markup_html(&raw).with_context(|| format!("Could not render message: {}", &raw))?;
     let bx = gtk::Box::new(gtk::Orientation::Vertical, 6);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]