From c033187650055ae54b67105dbf7468336d54af79 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl <14180120+JakobST1n@users.noreply.github.com> Date: Mon, 14 Feb 2022 11:32:02 +0100 Subject: :lock: Escape HTML special characters This will make all html tags not work, this _could_ be an issue for some feeds. Since we are using html2md for all content that advertises itself as html, I am going to assume it is fine for now :) --- src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index d84b082..54d7586 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,12 +41,16 @@ fn replace_tags(input: String, entry: &Entry) -> String { } /** - * Method that escapes some characters that would break json spec + * Method that escapes some characters that would break json spec, and also escape + * special HTML characters. */ fn escape(input: String) -> String { return input.replace("\\","\\\\") .replace("\"", "\\\"") - .replace("\n", "\\n"); + .replace("\n", "\\n") + .replace("<", "<") + .replace(">", ">") + .replace("&", "$amp;"); } /** -- cgit v1.2.3