Skip to content

Commit

Permalink
Tidy up is_domain func.
Browse files Browse the repository at this point in the history
  • Loading branch information
xkww3n committed Oct 15, 2023
1 parent 29b9eac commit 4cd81b3
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions Utils/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,14 @@ def is_ipaddr(addr: str) -> bool:


def is_domain(rule: Filter) -> bool:
blacklist_include = ("/", "*", "=", "~", "?", "#", ",", ":", " ", "(", ")", "[", "]", "_")
if (
rule.type == "filter"
and rule.selector["type"] == "url-pattern"
and "." in rule.text
and "/" not in rule.text
and "*" not in rule.text
and "=" not in rule.text
and "~" not in rule.text
and "?" not in rule.text
and "#" not in rule.text
and "," not in rule.text
and ":" not in rule.text
and " " not in rule.text
and ("(" or ")") not in rule.text
and not rule.text.startswith("_")
and not any([bl_char in rule.text for bl_char in blacklist_include])
and not rule.text.startswith("-")
and not rule.text.startswith("^")
and not rule.text.startswith("[")
and not rule.text.endswith(".")
and not rule.text.endswith("_")
and not rule.text.endswith("]")
and not rule.text.endswith(";")
and not rule.options
and not is_ipaddr(rule.text.strip("||").strip("^"))
):
Expand Down

0 comments on commit 4cd81b3

Please sign in to comment.