From c71460e4b69fc97b5ec5e50f5401ae4a9d12314c Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Tue, 28 Mar 2023 16:41:11 -0300 Subject: [PATCH 1/3] Allow TLD blocking using ABP style This validates patterns without dots (only for abp style), allowing TLDs to be blocked Signed-off-by: RD WebDesign --- gravity.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gravity.sh b/gravity.sh index a415aa01..19471cce 100755 --- a/gravity.sh +++ b/gravity.sh @@ -549,10 +549,12 @@ parseList() { # define valid domain patterns # no need to include uppercase letters, as we convert to lowercase in gravity_ParseFileIntoDomains() already # adapted from https://stackoverflow.com/a/30007882 - # supported ABP style: ||subdomain.domain.tlp^ valid_domain_pattern="([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]" - abp_domain_pattern="\|\|${valid_domain_pattern}\^" + + # supported ABP style: ||subdomain.domain.tld^ + # allow TLD blocking using ABP style: ||tld^ + abp_domain_pattern="\|\|([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)*[a-z0-9][a-z0-9-]{0,61}[a-z0-9]\^" # A list of items of common local hostnames not to report as unusable # Some lists (i.e StevenBlack's) contain these as they are supposed to be used as HOST files From 32fb2e69ff26e057bc6754197b5d343889dc63e7 Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Wed, 29 Mar 2023 00:02:42 -0300 Subject: [PATCH 2/3] Spliting the regex into TLD_pattern and subdomain_pattern Signed-off-by: RD WebDesign --- gravity.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gravity.sh b/gravity.sh index 19471cce..43159378 100755 --- a/gravity.sh +++ b/gravity.sh @@ -550,11 +550,14 @@ parseList() { # no need to include uppercase letters, as we convert to lowercase in gravity_ParseFileIntoDomains() already # adapted from https://stackoverflow.com/a/30007882 - valid_domain_pattern="([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]" + TLD_pattern="[a-z0-9][a-z0-9-]{0,61}[a-z0-9]" + subdomain_pattern="([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)" + + valid_domain_pattern="${subdomain_pattern}+${TLD_pattern}" # supported ABP style: ||subdomain.domain.tld^ - # allow TLD blocking using ABP style: ||tld^ - abp_domain_pattern="\|\|([a-z0-9]([a-z0-9_-]{0,61}[a-z0-9]){0,1}\.)*[a-z0-9][a-z0-9-]{0,61}[a-z0-9]\^" + # Subdomain is optional for ABP style, allowing TLD blocking: ||tld^ + abp_domain_pattern="\|\|${subdomain_pattern}*${TLD_pattern}\^" # A list of items of common local hostnames not to report as unusable # Some lists (i.e StevenBlack's) contain these as they are supposed to be used as HOST files From 66bfa606a7d2b3abb5ddffb673e23db6d5028985 Mon Sep 17 00:00:00 2001 From: RD WebDesign Date: Wed, 29 Mar 2023 14:17:41 -0300 Subject: [PATCH 3/3] Using a better text for the comment Signed-off-by: RD WebDesign --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 43159378..34cad67d 100755 --- a/gravity.sh +++ b/gravity.sh @@ -556,7 +556,7 @@ parseList() { valid_domain_pattern="${subdomain_pattern}+${TLD_pattern}" # supported ABP style: ||subdomain.domain.tld^ - # Subdomain is optional for ABP style, allowing TLD blocking: ||tld^ + # ${subdomain_pattern} is optional for ABP style, allowing TLD blocking: ||tld^ abp_domain_pattern="\|\|${subdomain_pattern}*${TLD_pattern}\^" # A list of items of common local hostnames not to report as unusable