unescape selftext_html from json api, fixes #354 (#357)

* unescape selftext_html from json api, fixes #354

* fix(fmt)

---------

Co-authored-by: Matthew Esposito <matt@matthew.science>
This commit is contained in:
Martin Lindhe 2025-02-03 03:56:47 +01:00 committed by GitHub
parent 9e47bc37c7
commit adf25cb15b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View file

@ -7,6 +7,7 @@ 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 log::error;
use once_cell::sync::Lazy;
@ -376,7 +377,7 @@ impl Post {
let awards = Awards::parse(&data["all_awardings"]);
// selftext_html is set for text posts when browsing.
let mut body = rewrite_urls(&val(post, "selftext_html"));
let mut body = rewrite_urls(&decode_html(&val(post, "selftext_html")).unwrap());
if body.is_empty() {
body = rewrite_urls(&val(post, "body_html"));
}