From 965a9d072453d5447f5cfdf9299b4e19d8787487 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Sat, 29 Mar 2025 09:39:01 -0400 Subject: [PATCH] Fix bug with new dig format --- .gitignore | 1 + src/dig_response.rs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index ea8c4bf..4c6fa16 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +result-bin diff --git a/src/dig_response.rs b/src/dig_response.rs index d4a36bd..b111134 100644 --- a/src/dig_response.rs +++ b/src/dig_response.rs @@ -56,7 +56,7 @@ impl DigResponse { pub fn query(domain: impl AsRef) -> anyhow::Result { let domain = domain.as_ref(); let start = Instant::now(); - let cmd = Command::new("dig") + let mut cmd = Command::new("dig") .arg("+yaml") .arg(domain) .output() @@ -76,7 +76,9 @@ impl DigResponse { String::from_utf8(if cmd.stdout.starts_with(b"-\n") { cmd.stdout.into_iter().skip(2).collect() } else { - cmd.stdout + let stdout = cmd.stdout.as_mut_slice(); + stdout[0] = b' '; + stdout.to_vec() }) // we skip two here --------------------------^ // because the dig output starts with "-\n" which fails to parse.