Browse Source

Split long TXT entries into 255 chunks

dpeca 5 years ago
parent
commit
f74301b19f
1 changed files with 14 additions and 0 deletions
  1. 14 0
      func/domain.sh

+ 14 - 0
func/domain.sh

@@ -412,6 +412,20 @@ update_domain_zone() {
             VALUE=$(idn --quiet -a -t "$VALUE")
         fi
 
+        # Split long TXT entries into 255 chunks
+        if [ "$TYPE" = 'TXT' ]; then
+            txtlength=${#VALUE}
+            if [ $txtlength -gt 255 ]; then
+                if [[ ${VALUE:0:1} = '"' ]]; then
+                    txtlength=$(( $txtlength - 2 ))
+                    VALUE=${VALUE:1:txtlength}
+                fi
+                VALUE=$(echo $VALUE | fold -w 255 | xargs -I '$' echo -n ' "$"')
+                VALUE=${VALUE:1}
+                VALUE="($VALUE)"
+            fi
+        fi
+
         if [ "$SUSPENDED" != 'yes' ]; then
             eval echo -e "\"$fields\""|sed "s/%quote%/'/g" >> $zn_conf
         fi