commit 7d991f1c48c30c098bc4c707be3fcd044205c0e1
parent 4692da80ef5fff19f684c4ea9ee26e623d39dbaf
Author: alex wennerberg <alex@alexwennerberg.com>
Date: Wed, 22 Dec 2021 15:27:45 -0800
add xml safety
Diffstat:
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/main.rs b/src/main.rs
@@ -21,6 +21,7 @@ use std::io::prelude::*;
use urlencoding;
use config::{Config, INSTANCE};
+use utils::xml_safe;
mod config;
mod mbox;
mod time;
@@ -109,12 +110,12 @@ impl<'a> ThreadList<'a> {
</author>
</feed>
"#,
- title = root.subject,
+ title = xml_safe(&root.subject),
item_link = "tbd",
entry_id = "tbd",
updated_at = "tbd",
- author_name = short_name(&root.from),
- author_email = &root.from.addr,
+ author_name = xml_safe(short_name(&root.from)),
+ author_email = xml_safe(&root.from.addr),
);
entries.push_str(&tmpl);
}
diff --git a/src/utils.rs b/src/utils.rs
@@ -65,7 +65,7 @@ pub fn email_body(body: &str) -> String {
}
// less efficient, easier api
-fn xml_safe(text: &str) -> String {
+pub fn xml_safe(text: &str) -> String {
// note we escape more than we need to
let mut dest = Vec::new();
xml_escape(text, &mut dest);