diff options
author | Jakob Stendahl <14180120+JakobST1n@users.noreply.github.com> | 2022-02-14 11:32:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-14 11:32:02 +0100 |
commit | c033187650055ae54b67105dbf7468336d54af79 (patch) | |
tree | 6b4d205746c4b3e4a52a480af61d4340f0c11ef3 | |
parent | d22c81fdc8593dc62b346766fcb81704ad138cfd (diff) | |
download | RSS-watcher-c033187650055ae54b67105dbf7468336d54af79.tar.gz RSS-watcher-c033187650055ae54b67105dbf7468336d54af79.zip |
: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 :)
-rw-r--r-- | src/main.rs | 8 |
1 files changed, 6 insertions, 2 deletions
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;"); } /** |