Fix problem with parsing output from different versions of dig

This commit is contained in:
D. Scott Boggs 2025-03-27 11:41:56 -04:00
parent 0207e365c7
commit 968e403307

View file

@ -73,7 +73,11 @@ impl DigResponse {
);
if cmd.status.success() {
Ok(serde_yaml_ng::from_str(
String::from_utf8(cmd.stdout.into_iter().skip(2).collect())
String::from_utf8(if cmd.stdout.starts_with(b"-\n") {
cmd.stdout.into_iter().skip(2).collect()
} else {
cmd.stdout
})
// we skip two here --------------------------^
// because the dig output starts with "-\n" which fails to parse.
.map_err(|error| {