Skip to content

Commit 3e3b30c

Browse files
leovctmattsseDaniPopes
authored
fix: cast --to-ascii does not work if input has trailing whitespaces (#8670)
* fix: `cast --to-ascii` removes trailing whitespaces on stdin * fix: remove extra break line returned by `cast call` * Update crates/cast/bin/main.rs Co-authored-by: Matthias Seitz <[email protected]> * Update crates/cast/src/lib.rs Co-authored-by: DaniPopes <[email protected]> * Update crates/cast/bin/main.rs Co-authored-by: DaniPopes <[email protected]> --------- Co-authored-by: Matthias Seitz <[email protected]> Co-authored-by: DaniPopes <[email protected]>
1 parent 224fe9c commit 3e3b30c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

crates/cast/bin/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async fn main() -> Result<()> {
6666
}
6767
CastSubcommand::ToAscii { hexdata } => {
6868
let value = stdin::unwrap(hexdata, false)?;
69-
println!("{}", SimpleCast::to_ascii(&value)?);
69+
println!("{}", SimpleCast::to_ascii(value.trim())?);
7070
}
7171
CastSubcommand::ToUtf8 { hexdata } => {
7272
let value = stdin::unwrap(hexdata, false)?;

crates/cast/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ where
168168

169169
// handle case when return type is not specified
170170
Ok(if decoded.is_empty() {
171-
format!("{res}\n")
171+
res.to_string()
172172
} else if json {
173173
let tokens = decoded.iter().map(format_token_raw).collect::<Vec<_>>();
174174
serde_json::to_string_pretty(&tokens).unwrap()
@@ -1503,7 +1503,7 @@ impl SimpleCast {
15031503
/// decoded[1].as_address().unwrap().to_string().to_lowercase(),
15041504
/// decoded[2].as_uint().unwrap().0.to_string(),
15051505
/// decoded[3].as_uint().unwrap().0.to_string(),
1506-
/// hex::encode(decoded[4].as_bytes().unwrap())
1506+
/// hex::encode(decoded[4].as_bytes().unwrap())
15071507
/// ]
15081508
/// .into_iter()
15091509
/// .collect::<Vec<_>>();

0 commit comments

Comments
 (0)