[fractal/wip/cdavis/next-style-cleanup: 2/2] room_title: Parse and escape markup for title and subtitle




commit 485963d3697e5a46ff451c2be7117a405e57f001
Author: Christopher Davis <christopherdavis gnome org>
Date:   Fri Jun 25 14:21:28 2021 -0700

    room_title: Parse and escape markup for title and subtitle
    
    Parsing and escaping markup fixes issues with special
    characters in titles and descriptions; Also allows links
    to work properly in descriptions.

 src/components/room_title.rs | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/src/components/room_title.rs b/src/components/room_title.rs
index 26698a66..52dce93e 100644
--- a/src/components/room_title.rs
+++ b/src/components/room_title.rs
@@ -2,6 +2,7 @@ use adw::subclass::prelude::*;
 use gtk::prelude::*;
 use gtk::subclass::prelude::*;
 use gtk::{glib, CompositeTemplate};
+use html2pango::markup;
 
 mod imp {
     use super::*;
@@ -104,6 +105,8 @@ impl RoomTitle {
 
     pub fn set_title(&self, title: Option<String>) {
         let priv_ = imp::RoomTitle::from_instance(self);
+        // Parse and escape markup in title
+        let title = title.map(|s| markup(&s));
         // If there's an existing title, check that current title and new title aren't equal
         if priv_.title.borrow().as_deref() != title.as_deref() {
             priv_.title.replace(title);
@@ -122,6 +125,8 @@ impl RoomTitle {
 
     pub fn set_subtitle(&self, subtitle: Option<String>) {
         let priv_ = imp::RoomTitle::from_instance(self);
+        // Parse and escape markup in subtitle
+        let subtitle = subtitle.map(|s| markup(&s));
         // If there's an existing subtitle, check that current subtitle and new subtitle aren't equal
         if priv_.subtitle.borrow().as_deref() != subtitle.as_deref() {
             priv_.subtitle.replace(subtitle);


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