add support for inverting whitelist
This commit is contained in:
parent
e89b79492b
commit
116c556e09
2 changed files with 18 additions and 7 deletions
|
@ -53,7 +53,7 @@ impl Options {
|
|||
.args_from_usage("-c, --no-css 'Removes CSS'")
|
||||
.args_from_usage("-C, --charset=[UTF-8] 'Enforces custom encoding'")
|
||||
.args_from_usage(
|
||||
"-D, --domains=[bad.org,ads.site,0.0.0.0,127.0.0.0:8080] 'Whitelist of domains'",
|
||||
"-D, --domains=[bad.org,ads.site,127.0.0.0:8080] 'Whitelist of domains'",
|
||||
)
|
||||
.args_from_usage("-e, --ignore-errors 'Ignore network errors'")
|
||||
.args_from_usage("-E, --exclude-domains 'Treat list of specified domains as blacklist'")
|
||||
|
|
23
src/utils.rs
23
src/utils.rs
|
@ -266,12 +266,23 @@ pub fn retrieve_asset(
|
|||
"".to_string(),
|
||||
))
|
||||
} else {
|
||||
if let Some(domains) = &options.domains {
|
||||
if domains
|
||||
.iter()
|
||||
.any(|d| domain_is_within_domain(url.host_str().unwrap(), &d.trim()))
|
||||
{
|
||||
return Err(client.get("").send().unwrap_err());
|
||||
if options.exclude_domains {
|
||||
if let Some(domains) = &options.domains {
|
||||
if domains
|
||||
.iter()
|
||||
.any(|d| domain_is_within_domain(url.host_str().unwrap(), &d.trim()))
|
||||
{
|
||||
return Err(client.get("").send().unwrap_err());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let Some(domains) = &options.domains {
|
||||
if domains
|
||||
.iter()
|
||||
.any(|d| !domain_is_within_domain(url.host_str().unwrap(), &d.trim()))
|
||||
{
|
||||
return Err(client.get("").send().unwrap_err());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue