encode url
All checks were successful
CI/CD Pipeline / test (push) Successful in 1m42s
CI/CD Pipeline / deploy (push) Successful in 1m44s

This commit is contained in:
Philipp Hofer
2025-10-13 09:57:59 +02:00
parent d6f22b4de7
commit 30cd6d2c97
3 changed files with 37 additions and 10 deletions

View File

@@ -16,21 +16,37 @@ pub async fn stream_handler(State(state): State<Arc<AppState>>) -> impl IntoResp
fn feed(urls: &Vec<String>) -> String {
let mut ret = String::new();
ret.push_str(r#"<?xml version="1.0" encoding="UTF-8"?>"#);
ret.push('\n');
ret.push_str(r#"<rss version="2.0">"#);
ret.push_str("<channel>");
ret.push_str("<title>Ö1 Morgenjournal Feed</title>");
ret.push_str("<link>https://news.hofer.link</link>");
ret.push_str("<description>Feed für Ö1 Morgenjournal. Live.</description>");
ret.push('\n');
ret.push_str(" <channel>");
ret.push('\n');
ret.push_str(" <title>Ö1 Morgenjournal Feed</title>");
ret.push('\n');
ret.push_str(" <link>https://news.hofer.link</link>");
ret.push('\n');
ret.push_str(" <description>Feed für Ö1 Morgenjournal. Live.</description>");
ret.push('\n');
for url in urls {
ret.push_str("<item>");
ret.push_str(&format!("<title>Morgenjournal DATE</title>"));
ret.push_str(&format!("<link>{url}</link>"));
ret.push_str(&format!("<description>{url}</description>"));
ret.push_str("</item>");
ret.push_str(" <item>");
ret.push('\n');
ret.push_str(&format!(" <title>Morgenjournal DATE</title>"));
ret.push('\n');
ret.push_str(&format!(
" <link>{}</link>",
quick_xml::escape::escape(url)
));
ret.push('\n');
ret.push_str(&format!(" <description>my desc</description>"));
ret.push('\n');
ret.push_str(" </item>");
ret.push('\n');
}
ret.push_str("</channel>");
ret.push_str(" </channel>");
ret.push('\n');
ret.push_str("</rss>");
ret
}