mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-22 14:58:08 +00:00
Escape dots in local DNS records/CNAMES before removing them
Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
parent
469a267150
commit
c322458dcb
@ -627,6 +627,12 @@ checkDomain()
|
|||||||
echo "${validDomain}"
|
echo "${validDomain}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
escapeDots()
|
||||||
|
{
|
||||||
|
escaped=$(sed 's/\./\\./g' <<< "$1" )
|
||||||
|
echo "${escaped}"
|
||||||
|
}
|
||||||
|
|
||||||
addAudit()
|
addAudit()
|
||||||
{
|
{
|
||||||
shift # skip "-a"
|
shift # skip "-a"
|
||||||
@ -702,6 +708,7 @@ RemoveCustomDNSAddress() {
|
|||||||
validHost="$(checkDomain "${host}")"
|
validHost="$(checkDomain "${host}")"
|
||||||
if [[ -n "${validHost}" ]]; then
|
if [[ -n "${validHost}" ]]; then
|
||||||
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
if valid_ip "${ip}" || valid_ip6 "${ip}" ; then
|
||||||
|
validHost=$(escapeDots "${validHost}")
|
||||||
sed -i "/^${ip} ${validHost}$/Id" "${dnscustomfile}"
|
sed -i "/^${ip} ${validHost}$/Id" "${dnscustomfile}"
|
||||||
else
|
else
|
||||||
echo -e " ${CROSS} Invalid IP has been passed"
|
echo -e " ${CROSS} Invalid IP has been passed"
|
||||||
@ -755,7 +762,9 @@ RemoveCustomCNAMERecord() {
|
|||||||
if [[ -n "${validDomain}" ]]; then
|
if [[ -n "${validDomain}" ]]; then
|
||||||
validTarget="$(checkDomain "${target}")"
|
validTarget="$(checkDomain "${target}")"
|
||||||
if [[ -n "${validTarget}" ]]; then
|
if [[ -n "${validTarget}" ]]; then
|
||||||
sed -i "/cname=${validDomain},${validTarget}$/Id" "${dnscustomcnamefile}"
|
validDomain=$(escapeDots "${validDomain}")
|
||||||
|
validTarget=$(escapeDots "${validTarget}")
|
||||||
|
sed -i "/^cname=${validDomain},${validTarget}$/Id" "${dnscustomcnamefile}"
|
||||||
else
|
else
|
||||||
echo " ${CROSS} Invalid Target Passed!"
|
echo " ${CROSS} Invalid Target Passed!"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user