Guard against hostnames/avahi responses with spaces

This commit is contained in:
Michael Bisbjerg 2025-04-06 01:10:27 +02:00 committed by GitHub
parent 646ec30ae5
commit bc099baeb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -74,11 +74,12 @@ discover_devices() {
exit 1 exit 1
fi fi
mapfile -t raw_devices < <(avahi-browse _wled._tcp --terminate -r -p | awk -F';' '/^=/ {print $7, $8, $9}') # Map avahi responses to strings seperated by 0x1F (unit separator)
mapfile -t raw_devices < <(avahi-browse _wled._tcp --terminate -r -p | awk -F';' '/^=/ {print $7"\x1F"$8"\x1F"$9}')
local devices_array=() local devices_array=()
for device in "${raw_devices[@]}"; do for device in "${raw_devices[@]}"; do
read -r hostname address port <<< "$device" IFS=$'\x1F' read -r hostname address port <<< "$device"
devices_array+=("$hostname" "$address" "$port") devices_array+=("$hostname" "$address" "$port")
done done