Skip to content

Commit d6ec14c

Browse files
LupulKristan Kenney
authored andcommitted
Fix quoting when adding CAA dns records (hestiacp#304)
- use correct <flags> <tag> order
1 parent 1ff3fc6 commit d6ec14c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

bin/v-add-dns-record

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,16 @@ if [[ $rtype =~ NS|CNAME|MX|PTR|SRV ]]; then
4545
fi
4646
fi
4747

48-
if [ $rtype != "CAA" ]; then
49-
dvalue=${dvalue//\"/}
50-
# Exclude CAA records for ' enclosure
51-
if [[ "$dvalue" =~ [\;[:space:]] ]]; then
52-
dvalue='"'"$dvalue"'"'
53-
fi
54-
fi
48+
# Cleanup quotes on dvalue
49+
# - [CAA] records will be left unchanged
50+
# - [SRV] will be stripped of double quotes even when containg spaces
51+
# - Rest of record types will be striped of quotes and the final string
52+
# will be enclosed in double quotes if containg spaces or semicolons
5553

56-
if [[ "$dvalue" =~ [\;[:space:]] ]]; then
54+
if [ "$rtype" != "CAA" ]; then
5755
dvalue=${dvalue//\"/}
58-
# Exclude SRV records for ' enclosure
59-
if [ "$rtype" != 'SRV' ]; then
56+
57+
if [ "$rtype" != 'SRV' ] && [[ "$dvalue" =~ [\;[:space:]] ]]; then
6058
dvalue='"'"$dvalue"'"'
6159
fi
6260
fi

bin/v-add-letsencrypt-domain

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ if [ ! -z "$DNS_SYSTEM" ]; then
132132
if [ "$dns_domain" = "$domain" ]; then
133133
# Replace DNS domain CAA records with Let's Encrypt values
134134
if [ -z "$caa_record" ]; then
135-
$BIN/v-add-dns-record $user $domain '@' 'CAA' 'issue 0 "letsencrypt.org"'
135+
$BIN/v-add-dns-record $user $domain '@' 'CAA' '0 issue "letsencrypt.org"'
136136
else
137137
$BIN/v-delete-dns-record $user $domain $caa_record
138-
$BIN/v-add-dns-record $user $domain '@' 'CAA' 'issue 0 "letsencrypt.org"'
138+
$BIN/v-add-dns-record $user $domain '@' 'CAA' '0 issue "letsencrypt.org"'
139139
fi
140140
fi
141141
fi

0 commit comments

Comments
 (0)