1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-11-18 14:18:15 +00:00

Improve comments

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2019-05-04 13:19:50 +02:00
parent 6ba58896d2
commit f80fdd7e83
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD

View File

@ -108,10 +108,10 @@ scanDatabaseTable() {
table="${2}"
type="${3:-}"
# As underscores are legitimate parts of domains, we escape possible them when using the LIKE operator.
# Underscores are a SQLite wildcard matching exactly one character. We obviously want to suppress this
# As underscores are legitimate parts of domains, we escape them when using the LIKE operator.
# Underscores are SQLite wildcards matching exactly one character. We obviously want to suppress this
# behavior. The "ESCAPE '\'" clause specifies that an underscore preceded by an '\' should be matched
# as a literal underscore character.
# as a literal underscore character. We pretreat the $domain variable accordingly to escape underscores.
case "${type}" in
"exact" ) querystr="SELECT domain FROM vw_${table} WHERE domain = '${domain}'";;
* ) querystr="SELECT domain FROM vw_${table} WHERE domain LIKE '%${domain//_/\\_}%' ESCAPE '\'";;
@ -120,13 +120,14 @@ scanDatabaseTable() {
# Send prepared query to gravity database
result="$(sqlite3 "${gravityDBfile}" "${querystr}")" 2> /dev/null
if [[ -z "${result}" ]]; then
# Return early when we have no results
# Return early when there are no matches in this table
return
fi
# Mark domain as having been white-/blacklist matched (global variable)
wbMatch=true
mapfile -t results <<< "${result}"
# Loop through each result
mapfile -t results <<< "${result}"
for result in "${results[@]}"; do
if [[ -n "${blockpage}" ]]; then
echo "π ${result}"