From 43971e29a1ec2cfaa0d6c5d6b42100728dd8b1fc Mon Sep 17 00:00:00 2001
From: Dirk Brenken <dev@brenken.org>
Date: Fri, 6 Jan 2017 16:10:18 +0100
Subject: [PATCH] adblock: bugfix 2.1.1

* fix domain query function to support new unbound format

Signed-off-by: Dirk Brenken <dev@brenken.org>
---
 net/adblock/Makefile         |  2 +-
 net/adblock/files/adblock.sh | 14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/net/adblock/Makefile b/net/adblock/Makefile
index de4844ba2..20b141931 100644
--- a/net/adblock/Makefile
+++ b/net/adblock/Makefile
@@ -6,7 +6,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=adblock
-PKG_VERSION:=2.1.0
+PKG_VERSION:=2.1.1
 PKG_RELEASE:=1
 PKG_LICENSE:=GPL-3.0+
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
diff --git a/net/adblock/files/adblock.sh b/net/adblock/files/adblock.sh
index 95b943483..771857fc0 100755
--- a/net/adblock/files/adblock.sh
+++ b/net/adblock/files/adblock.sh
@@ -10,7 +10,7 @@
 #
 LC_ALL=C
 PATH="/usr/sbin:/usr/bin:/sbin:/bin"
-adb_ver="2.1.0"
+adb_ver="2.1.1"
 adb_enabled=1
 adb_debug=0
 adb_whitelist="/etc/adblock/adblock.whitelist"
@@ -251,20 +251,20 @@ f_query()
 
     if [ -z "${dns_active}" ]
     then
-         printf "%s\n" ":: no active block lists found, please start adblock first"
+         printf "%s\n" "::: no active block lists found, please start adblock first"
     elif [ -z "${domain}" ] || [ "${domain}" = "${tld}" ]
     then
-        printf "%s\n" ":: invalid domain input, please submit a specific (sub-)domain, i.e. 'www.abc.xyz'"
+        printf "%s\n" "::: invalid domain input, please submit a specific (sub-)domain, i.e. 'www.abc.xyz'"
     else
+        cd "${adb_dnsdir}"
         while [ "${domain}" != "${tld}" ]
         do
             search="${domain//./\.}"
-            result="$(grep -Hm 1 "[/\.]${search}/" "${adb_dnsdir}/${adb_dnsprefix}"* | awk -F ':|/' '{print "   "$4"\t: "$6}')"
-            cnt="$(grep -hc "[/\.]${search}/" "${adb_dnsdir}/${adb_dnsprefix}"* | awk '{sum += $1} END {printf sum}')"
-            printf "%s\n" ":: distinct results for domain '${domain}' (overall ${cnt})"
+            result="$(grep -Hm1 "[/\"\.]${search}[/\"]" "${adb_dnsprefix}"* | awk -F ':|=|/|\"' '{printf(" %-20s : %s\n",$1,$4)}')"
+            printf "%s\n" "::: distinct results for domain '${domain}'"
             if [ -z "${result}" ]
             then
-                printf "%s\n" "   no matches in active block lists"
+                printf "%s\n" " no match"
             else
                 printf "%s\n" "${result}"
             fi