diff --git a/Cargo.lock b/Cargo.lock index 1443b16..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" @@ -1492,10 +1498,11 @@ dependencies = [ [[package]] name = "scootaloo" -version = "0.1.4" +version = "0.1.5" dependencies = [ "clap", "egg-mode", + "htmlescape", "mammut", "reqwest 0.10.3", "serde", diff --git a/Cargo.toml b/Cargo.toml index fae1731..0466cc3 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" @@ -17,3 +17,5 @@ egg-mode = "^0.13" mammut = "^0.13" reqwest = { version = "^0.10", features = ["blocking"] } + +htmlescape = "^0.3" 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)) }