diff --git a/src/app/browser/bookmarks.rs b/src/app/browser/bookmarks.rs index f74bf4dc..95b4702d 100644 --- a/src/app/browser/bookmarks.rs +++ b/src/app/browser/bookmarks.rs @@ -73,7 +73,7 @@ impl Bookmarks for adw::PreferencesDialog { .format_iso8601() .unwrap(), ) - .title(group) + .title(escape(&group)) .build(); for record in records { @@ -86,7 +86,7 @@ impl Bookmarks for adw::PreferencesDialog { None => record.time.format_iso8601().unwrap().to_string(), }) .subtitle_selectable(true) - .subtitle(&record.request) + .subtitle(escape(&record.request)) .build(); a.add_suffix(&{ @@ -126,3 +126,8 @@ impl Bookmarks for adw::PreferencesDialog { d } } + +/// Prevents GTK warnings (`use_markup` has no effect @TODO) +fn escape(value: &str) -> String { + value.replace("&", "&").replace("&", "&") +} diff --git a/src/app/browser/history.rs b/src/app/browser/history.rs index 8b8c5cdd..17d8f66d 100644 --- a/src/app/browser/history.rs +++ b/src/app/browser/history.rs @@ -11,7 +11,7 @@ use adw::{ }; use gtk::{ Align, Button, - glib::{DateTime, GString, Uri, UriFlags, gformat}, + glib::{DateTime, GString, Uri, UriFlags}, prelude::ButtonExt, }; use indexmap::IndexMap; @@ -85,7 +85,7 @@ impl History for adw::PreferencesDialog { .format_iso8601() .unwrap(), ) - .title(group) + .title(escape(&group)) .build(); for record in records { @@ -94,14 +94,14 @@ impl History for adw::PreferencesDialog { .activatable(false) .title_selectable(true) .title(match record.title { - Some(title) => title, - None => gformat!( + Some(title) => escape(&title), + None => format!( "{} ({})", record.event.time.format_iso8601().unwrap(), record.event.count ), }) - .subtitle(&*record.request) + .subtitle(escape(&record.request)) .subtitle_selectable(true) .build(); @@ -150,3 +150,8 @@ impl History for adw::PreferencesDialog { d } } + +/// Prevents GTK warnings (`use_markup` has no effect @TODO) +fn escape(value: &str) -> String { + value.replace("&", "&").replace("&", "&") +}