From c322458dcb568604c94b6c359863b21fd88dc13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 21 Oct 2022 12:25:23 +0200 Subject: [PATCH 1/3] Escape dots in local DNS records/CNAMES before removing them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- advanced/Scripts/webpage.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index e02e03f9..f4a452fe 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -627,6 +627,12 @@ checkDomain() echo "${validDomain}" } +escapeDots() +{ + escaped=$(sed 's/\./\\./g' <<< "$1" ) + echo "${escaped}" +} + addAudit() { shift # skip "-a" @@ -702,6 +708,7 @@ RemoveCustomDNSAddress() { validHost="$(checkDomain "${host}")" if [[ -n "${validHost}" ]]; then if valid_ip "${ip}" || valid_ip6 "${ip}" ; then + validHost=$(escapeDots "${validHost}") sed -i "/^${ip} ${validHost}$/Id" "${dnscustomfile}" else echo -e " ${CROSS} Invalid IP has been passed" @@ -755,7 +762,9 @@ RemoveCustomCNAMERecord() { if [[ -n "${validDomain}" ]]; then validTarget="$(checkDomain "${target}")" 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 echo " ${CROSS} Invalid Target Passed!" exit 1 From df3e9e5f5108636404e3dea80201868f02fc739c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 21 Oct 2022 14:31:16 +0200 Subject: [PATCH 2/3] Disable shellcheck as it suggests a bashism MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- advanced/Scripts/webpage.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index f4a452fe..7c112d00 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -629,6 +629,8 @@ checkDomain() escapeDots() { + # shellcheck disable=SC2001 + # SH suggest bashism ${variable//search/replace} escaped=$(sed 's/\./\\./g' <<< "$1" ) echo "${escaped}" } From 128a3ab1becbdd4815a85a35ebeefeec1f7f6e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sat, 22 Oct 2022 22:37:05 +0200 Subject: [PATCH 3/3] Go POSIX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- advanced/Scripts/webpage.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/webpage.sh b/advanced/Scripts/webpage.sh index 7c112d00..53d631cd 100755 --- a/advanced/Scripts/webpage.sh +++ b/advanced/Scripts/webpage.sh @@ -629,9 +629,9 @@ checkDomain() escapeDots() { + # SC suggest bashism ${variable//search/replace} # shellcheck disable=SC2001 - # SH suggest bashism ${variable//search/replace} - escaped=$(sed 's/\./\\./g' <<< "$1" ) + escaped=$(echo "$1" | sed 's/\./\\./g') echo "${escaped}" }