~exprez135/castor

d401d48174adc07ecd909419c08c33c65740f915 — Julien Blanchard 1 year, 5 months ago b1968bf 0.8.2
Escape text before putting it in a pango span
3 files changed, 19 insertions(+), 9 deletions(-)

M Cargo.lock
M Cargo.toml
M src/draw.rs
M Cargo.lock => Cargo.lock +1 -1
@@ 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)",

M Cargo.toml => Cargo.toml +1 -1
@@ 1,6 1,6 @@
[package]
name = "castor"
version = "0.8.1"
version = "0.8.2"
authors = ["Julien Blanchard <julien@typed-hole.org>"]
edition = "2018"


M src/draw.rs => src/draw.rs +17 -7
@@ 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())
}