1
0
mirror of https://github.com/pi-hole/pi-hole synced 2024-11-19 06:38:17 +00:00

Properly escape domain regex

Dots in domain names should not match any character.

Signed-off-by: Niklas Elmose Andersen <mail@niklasea.dk>
This commit is contained in:
Niklas Elmose Andersen 2019-08-27 12:13:28 +02:00
parent 989d1aff60
commit a3e32d9a15

View File

@ -176,11 +176,12 @@ fi
# 2. Remove comments after domain # 2. Remove comments after domain
# 3. Remove hosts format IP address # 3. Remove hosts format IP address
# 4. Remove any lines that no longer contain the queried domain name (in case the matched domain name was in a comment) # 4. Remove any lines that no longer contain the queried domain name (in case the matched domain name was in a comment)
esc_domain="${domainQuery//./\\.}"
mapfile -t results <<< "$(IFS=$'\n'; sed \ mapfile -t results <<< "$(IFS=$'\n'; sed \
-e "/:#/d" \ -e "/:#/d" \
-e "s/[ \\t]#.*//g" \ -e "s/[ \\t]#.*//g" \
-e "s/:.*[ \\t]/:/g" \ -e "s/:.*[ \\t]/:/g" \
-e "/${domainQuery}/!d" \ -e "/${esc_domain}/!d" \
<<< "${results[*]}")" <<< "${results[*]}")"
# Exit if result was in a comment # Exit if result was in a comment
[[ -z "${results[*]}" ]] && exit 0 [[ -z "${results[*]}" ]] && exit 0