From b0fedfa87563b0fd050a132abb3cd4deb8e67b93 Mon Sep 17 00:00:00 2001 From: VC Date: Tue, 3 Mar 2020 18:34:08 +0100 Subject: [PATCH 1/3] Bump version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1443b16..be7187d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1492,7 +1492,7 @@ dependencies = [ [[package]] name = "scootaloo" -version = "0.1.4" +version = "0.1.5" dependencies = [ "clap", "egg-mode", diff --git a/Cargo.toml b/Cargo.toml index fae1731..0dbaa6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "scootaloo" -version = "0.1.4" +version = "0.1.5" authors = ["VC "] edition = "2018" From 342b1c17001fc03e92e63867f835613371da7e1c Mon Sep 17 00:00:00 2001 From: VC Date: Tue, 3 Mar 2020 18:38:36 +0100 Subject: [PATCH 2/3] Add htmlescape --- Cargo.lock | 7 +++++++ Cargo.toml | 2 ++ 2 files changed, 9 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index be7187d..4915a4f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -620,6 +620,12 @@ dependencies = [ "digest", ] +[[package]] +name = "htmlescape" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" + [[package]] name = "http" version = "0.1.21" @@ -1496,6 +1502,7 @@ version = "0.1.5" dependencies = [ "clap", "egg-mode", + "htmlescape", "mammut", "reqwest 0.10.3", "serde", diff --git a/Cargo.toml b/Cargo.toml index 0dbaa6f..0466cc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,5 @@ egg-mode = "^0.13" mammut = "^0.13" reqwest = { version = "^0.10", features = ["blocking"] } + +htmlescape = "^0.3" From aae59f641e7721ded7cf2f7eefd89e0cac396592 Mon Sep 17 00:00:00 2001 From: VC Date: Tue, 3 Mar 2020 18:38:49 +0100 Subject: [PATCH 3/3] 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)) }