-- Leo's gemini proxy
-- Connecting to typed-hole.org:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
commit d401d48174adc07ecd909419c08c33c65740f915
Author: Julien Blanchard <julien@sideburns.eu>
Date: Fri May 8 18:33:36 2020 +0200
Escape text before putting it in a pango span
diff --git a/Cargo.lock b/Cargo.lock
index c4390e4..4427890 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -136,7 +136,7 @@ dependencies = [
[[package]]
name = "castor"
-version = "0.8.1"
+version = "0.8.2"
dependencies = [
"ansi-parser 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index ed3ed74..2fbd732 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "castor"
-version = "0.8.1"
+version = "0.8.2"
authors = ["Julien Blanchard <julien@typed-hole.org>"]
edition = "2018"
diff --git a/src/draw.rs b/src/draw.rs
index d03c97e..072b44c 100644
--- a/src/draw.rs
+++ b/src/draw.rs
@@ -36,7 +36,7 @@ pub fn gemini_content(
crate::settings::h1_color(),
font_family,
crate::settings::h1_character(),
- header
+ escape_text(&header)
),
);
}
@@ -49,7 +49,7 @@ pub fn gemini_content(
crate::settings::h2_color(),
font_family,
crate::settings::h2_character(),
- header
+ escape_text(&header)
),
);
}
@@ -62,7 +62,7 @@ pub fn gemini_content(
crate::settings::h3_color(),
font_family,
crate::settings::h3_character(),
- header
+ escape_text(&header)
),
);
}
@@ -75,7 +75,7 @@ pub fn gemini_content(
crate::settings::list_color(),
font_family,
crate::settings::list_character(),
- item
+ escape_text(&item)
),
);
}
@@ -84,6 +84,12 @@ pub fn gemini_content(
}
Ok(crate::gemini::parser::TextElement::Text(text)) => {
let mut end_iter = buffer.get_end_iter();
+ let text = if text.contains("<span") {
+ text
+ } else {
+ escape_text(&text)
+ };
+
if mono_toggle {
buffer.insert_markup(
&mut end_iter,
@@ -130,7 +136,7 @@ pub fn gemini_text_content(
&format!(
"<span foreground=\"{}\" font_family=\"monospace\">{}</span>\n",
crate::settings::text_color(),
- text
+ escape_text(&text)
),
);
}
@@ -164,7 +170,7 @@ pub fn gopher_content(
"<span foreground=\"{}\" {}>{}</span>\n",
crate::settings::text_color(),
font_family,
- text
+ escape_text(&text)
),
);
}
@@ -206,7 +212,7 @@ pub fn finger_content(
"<span foreground=\"{}\" {}>{}</span>\n",
crate::settings::text_color(),
font_family,
- text
+ escape_text(&text)
),
);
}
@@ -374,3 +380,7 @@ pub fn insert_external_button(gui: &Arc<Gui>, url: Url, label: &str) {
let mut end_iter = buffer.get_end_iter();
buffer.insert(&mut end_iter, "\n");
}
+
+fn escape_text(str: &str) -> String {
+ String::from(glib::markup_escape_text(&str).as_str())
+}
---
Served by Pollux Gemini Server.
-- Response ended
-- Page fetched on Sun May 19 04:17:38 2024