From 7086a400e8a60f70f2e6ea577087b5e38d5cadd5 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Tue, 31 Jul 2018 21:36:29 -0400 Subject: [PATCH] Use simpler regex format for wildcards Use `\.?domain\.com$` instead of `((^)|(\.))domain\.com$` Signed-off-by: Mcat12 --- advanced/Scripts/list.sh | 4 ++-- advanced/Scripts/wildcard_regex_converter.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/list.sh b/advanced/Scripts/list.sh index 095e1274..4c0c0b8e 100755 --- a/advanced/Scripts/list.sh +++ b/advanced/Scripts/list.sh @@ -141,7 +141,7 @@ AddDomain() { bool=true domain="${1}" - [[ "${wildcard}" == true ]] && domain="((^)|(\\.))${domain//\./\\.}$" + [[ "${wildcard}" == true ]] && domain="\\.?${domain//\./\\.}$" # Is the domain in the list? # Search only for exactly matching lines @@ -189,7 +189,7 @@ RemoveDomain() { [[ -z "${type}" ]] && type="--wildcard-only" domain="${1}" - [[ "${wildcard}" == true ]] && domain="((^)|(\\.))${domain//\./\\.}$" + [[ "${wildcard}" == true ]] && domain="\\.?${domain//\./\\.}$" bool=true # Is it in the list? diff --git a/advanced/Scripts/wildcard_regex_converter.sh b/advanced/Scripts/wildcard_regex_converter.sh index 2db4d671..43d4a532 100644 --- a/advanced/Scripts/wildcard_regex_converter.sh +++ b/advanced/Scripts/wildcard_regex_converter.sh @@ -24,5 +24,5 @@ convert_wildcard_to_regex() { # Remove repeated domains (may have been inserted two times due to A and AAAA blocking) uniquedomains="$(uniq <<< "${domains}")" # Automatically generate regex filters and remove old wildcards file - awk '{print "((^)|(\\.))"$0"$"}' <<< "${uniquedomains}" >> "${regexFile:?}" && rm "${wildcardFile}" + awk '{print "\\.?"$0"$"}' <<< "${uniquedomains}" >> "${regexFile:?}" && rm "${wildcardFile}" }