Fix allowlist logic (#520)

This commit is contained in:
Denis Isidoro 2021-04-17 12:06:29 -03:00 committed by GitHub
parent 9d9ae304ba
commit 639e1dc46a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -111,13 +111,7 @@ fn write_cmd(
if item.snippet.len() <= 1 {
return Ok(());
}
if let Some(list) = allowlist {
for v in list {
if !item.tags.contains(v) {
return Ok(());
}
}
}
if let Some(list) = denylist {
for v in list {
if item.tags.contains(v) {
@ -125,6 +119,20 @@ fn write_cmd(
}
}
}
if let Some(list) = allowlist {
let mut should_allow = false;
for v in list {
if item.tags.contains(v) {
should_allow = true;
break;
}
}
if !should_allow {
return Ok(());
}
}
return stdin
.write_all(writer::write(item).as_bytes())
.context("Failed to write command to finder's stdin");