diff --git a/src/subreddit.rs b/src/subreddit.rs index d03a9dd..e6d1cca 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -8,6 +8,7 @@ use crate::utils::{ }; use crate::{client::json, server::RequestExt, server::ResponseExt}; use cookie::Cookie; +use htmlescape::decode_html; use hyper::{Body, Request, Response}; use log::debug; use rinja::Template; @@ -623,7 +624,7 @@ pub async fn rss(req: Request) -> Result, String> { title: Some(post.title.to_string()), link: Some(format_url(&utils::get_post_url(&post))), author: Some(post.author.name), - content: Some(rewrite_urls(&post.body)), + content: Some(rewrite_urls(&decode_html(&post.body).unwrap())), pub_date: Some(DateTime::from_timestamp(post.created_ts as i64, 0).unwrap_or_default().to_rfc2822()), description: Some(format!( "Comments", diff --git a/src/user.rs b/src/user.rs index 818f368..592389d 100644 --- a/src/user.rs +++ b/src/user.rs @@ -6,6 +6,7 @@ use crate::server::RequestExt; use crate::utils::{error, filter_posts, format_url, get_filters, nsfw_landing, param, setting, template, Post, Preferences, User}; use crate::{config, utils}; use chrono::DateTime; +use htmlescape::decode_html; use hyper::{Body, Request, Response}; use rinja::Template; use time::{macros::format_description, OffsetDateTime}; @@ -167,7 +168,7 @@ pub async fn rss(req: Request) -> Result, String> { link: Some(format_url(&utils::get_post_url(&post))), author: Some(post.author.name), pub_date: Some(DateTime::from_timestamp(post.created_ts as i64, 0).unwrap_or_default().to_rfc2822()), - content: Some(rewrite_urls(&post.body)), + content: Some(rewrite_urls(&decode_html(&post.body).unwrap())), ..Default::default() }) .collect::>(), diff --git a/src/utils.rs b/src/utils.rs index c4ab679..f5046cb 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -7,7 +7,6 @@ use crate::config::{self, get_setting}; // use crate::{client::json, server::RequestExt}; use cookie::Cookie; -use htmlescape::decode_html; use hyper::{Body, Request, Response}; use libflate::deflate::{Decoder, Encoder}; use log::error; @@ -388,7 +387,7 @@ impl Post { let awards = Awards::parse(&data["all_awardings"]); // selftext_html is set for text posts when browsing. - let mut body = rewrite_urls(&decode_html(&val(post, "selftext_html")).unwrap()); + let mut body = rewrite_urls(&val(post, "selftext_html")); if body.is_empty() { body = rewrite_urls(&val(post, "body_html")); }