mirror of
https://github.com/redlib-org/redlib.git
synced 2025-04-02 04:37:35 +03:00
* unescape selftext_html from json api, fixes #354 * fix(fmt) --------- Co-authored-by: Matthew Esposito <matt@matthew.science>
This commit is contained in:
parent
9e47bc37c7
commit
adf25cb15b
3 changed files with 10 additions and 1 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -770,6 +770,12 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc"
|
||||
|
||||
[[package]]
|
||||
name = "htmlescape"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163"
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.12"
|
||||
|
@ -1367,6 +1373,7 @@ dependencies = [
|
|||
"dotenvy",
|
||||
"fastrand",
|
||||
"futures-lite",
|
||||
"htmlescape",
|
||||
"hyper",
|
||||
"hyper-rustls",
|
||||
"libflate",
|
||||
|
|
|
@ -51,6 +51,7 @@ common-words-all = { version = "0.0.2", default-features = false, features = ["e
|
|||
hyper-rustls = { version = "0.24.2", features = [ "http2" ] }
|
||||
tegen = "0.1.4"
|
||||
serde_urlencoded = "0.7.1"
|
||||
htmlescape = "0.3.1"
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue