[fractal] room-history: Escape HTML entities in URLs tooltips



commit f56b28bb44d5493f2a35f6a60aa091ea97df5c69
Author: Kévin Commaille <zecakeh tedomum fr>
Date:   Sun Oct 9 15:25:46 2022 +0200

    room-history: Escape HTML entities in URLs tooltips
    
    The tooltips consider that there is markup by default and don't like '&' that
    are not escaped.

 src/session/content/room_history/message_row/text.rs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/session/content/room_history/message_row/text.rs 
b/src/session/content/room_history/message_row/text.rs
index 6951a1d6c..bf23a3a79 100644
--- a/src/session/content/room_history/message_row/text.rs
+++ b/src/session/content/room_history/message_row/text.rs
@@ -175,10 +175,14 @@ fn hoverify_links(text: &str) -> String {
 
     for (i, chunk) in text.split_inclusive("<a href=\"").enumerate() {
         if i > 0 {
-            if let Some((url, _)) = chunk.split_once('"') {
-                write!(&mut res, "{url}\" title=\"").unwrap();
+            if let Some((url, end)) = chunk.split_once('"') {
+                let escaped_url = html_escape(url);
+                write!(&mut res, "{url}\" title=\"{escaped_url}\"{end}").unwrap();
+
+                continue;
             }
         }
+
         res.push_str(chunk);
     }
 


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