From 28f5c3ccb58e17f27f0886ef5a8343f117d6516a Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 17 Jul 2022 11:51:34 +0000 Subject: fix(gemini_to_html.rs): html entity-encode gemini --- Cargo.toml | 5 ++++- src/gemini_to_html.rs | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a7546c8..165d0c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "september" -version = "0.2.0" +version = "0.2.1" authors = ["Fuwn "] edition = "2021" description = "A simple and efficient Gemini-to-HTTP proxy." @@ -34,6 +34,9 @@ log = "0.4.16" # Environment Variables dotenv = "0.15.0" +# HTML Entity-encode Text +htmlescape = "0.3.1" + [build-dependencies] # Environment Variables vergen = "7.0.0" diff --git a/src/gemini_to_html.rs b/src/gemini_to_html.rs index 870910b..845c568 100644 --- a/src/gemini_to_html.rs +++ b/src/gemini_to_html.rs @@ -42,8 +42,9 @@ pub fn gemini_to_html( url: &Url, is_proxy: bool, ) -> (String, String) { - let ast_tree = - germ::ast::Ast::from_string(&String::from_utf8_lossy(&response.data)); + let ast_tree = germ::ast::Ast::from_string(&htmlescape::encode_minimal( + &String::from_utf8_lossy(&response.data), + )); let ast = ast_tree.inner(); let mut html = String::new(); let mut title = "".to_string(); -- cgit v1.2.3