Escape output with html_escape
This commit is contained in:
parent
401560b611
commit
3247635cb4
4 changed files with 23 additions and 8 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -315,6 +315,7 @@ dependencies = [
|
|||
"anyhow",
|
||||
"clap",
|
||||
"color-eyre",
|
||||
"html-escape",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
@ -346,6 +347,15 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "html-escape"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "816ea801a95538fc5f53c836697b3f8b64a9d664c4f0b91efe1fe7c92e4dbcb7"
|
||||
dependencies = [
|
||||
"utf8-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.5"
|
||||
|
@ -1203,6 +1213,12 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf8-width"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cf7d77f457ef8dfa11e4cd5933c5ddb5dc52a94664071951219a97710f0a32b"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
|
|
|
@ -9,6 +9,7 @@ edition = "2021"
|
|||
anyhow = "1.0.52"
|
||||
clap = "3.0.0-beta.2"
|
||||
color-eyre = "0.6.0"
|
||||
html-escape = "0.2.9"
|
||||
reqwest = { version = "0.11.4", features = ["blocking", "json"] }
|
||||
serde = { version = "1.0.126", features = ["derive"] }
|
||||
serde_json = "1.0.64"
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
devShell = with pkgs; mkShell {
|
||||
inherit buildInputs;
|
||||
nativeBuildInputs = [ cargo-edit cargo-expand cargo-diet cargo-feature cargo-outdated pre-commit jq ] ++ nativeBuildInputs;
|
||||
nativeBuildInputs = [ cargo-edit cargo-expand cargo-diet cargo-feature cargo-outdated rust-analyzer pre-commit jq ] ++ nativeBuildInputs;
|
||||
};
|
||||
|
||||
});
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -158,14 +158,12 @@ fn get_now_playing(host: String, entity: String, insecure: bool, token: String)
|
|||
format!("{volume}{artist} - {title}")
|
||||
};
|
||||
|
||||
println!("{}", now_playing);
|
||||
println!("{}", html_escape::encode_text(&now_playing));
|
||||
} else {
|
||||
println!(
|
||||
"Sonos {}",
|
||||
response["state"]
|
||||
let state = response["state"]
|
||||
.as_str()
|
||||
.map_or("state unknown", |state| state)
|
||||
);
|
||||
.map_or("State unknown", |state| state);
|
||||
println!("Sonos {}", html_escape::encode_text(state));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in a new issue