From aae59f641e7721ded7cf2f7eefd89e0cac396592 Mon Sep 17 00:00:00 2001 From: VC Date: Tue, 3 Mar 2020 18:38:49 +0100 Subject: [PATCH] Decode HTML Entities inside Tweet --- src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8c92ddc..dcf1329 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -37,6 +37,9 @@ use mammut::{ // reqwest use reqwest::blocking::Client; +// htmlescape +use htmlescape::decode_html; + /********** * Generic usage functions ***********/ @@ -144,9 +147,9 @@ fn build_basic_status(tweet: &Tweet) -> Result> { toot = toot.replace(&decoded_url.0, &decoded_url.1); } - // remove the & and replace it with & - // this is the only entities and/or char that is not available via Twitter API - toot = toot.replace("&", "&"); + if let Ok(t) = decode_html(&toot) { + toot = t; + } Ok(StatusBuilder::new(toot)) }