From cbc0b243058f52111cb2c5755579691dd0d129ee Mon Sep 17 00:00:00 2001 From: yorickdowne <71337066+yorickdowne@users.noreply.github.com> Date: Mon, 5 Feb 2024 04:52:12 -0500 Subject: [PATCH] Better graffiti input check (#1730) --- ethd | 10 +++++++++- vc-utils/keymanager.sh | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ethd b/ethd index d84347ec..998f4760 100755 --- a/ethd +++ b/ethd @@ -2881,9 +2881,17 @@ query_graffiti() { var="GRAFFITI" GRAFFITI=$(sed -n -e "s/^${var}=\(.*\)/\1/p" "${ENV_FILE}" || true) - GRAFFITI=$(whiptail --title "Configure Graffiti" --inputbox "What Graffiti do you want to send with your blocks? \ + while true; do + GRAFFITI=$(whiptail --title "Configure Graffiti" --inputbox "What Graffiti do you want to send with your blocks? \ (up to 32 characters)" 10 65 "${GRAFFITI}" 3>&1 1>&2 2>&3) + if [[ $(echo -n "${GRAFFITI}" | wc -c) -gt 32 ]]; then + whiptail --msgbox "The graffiti string cannot be longer than 32 characters. Emojis count as 4, each." 16 65 + else + break + fi + done + echo "your Graffiti is:" "${GRAFFITI}" } diff --git a/vc-utils/keymanager.sh b/vc-utils/keymanager.sh index c838c9f7..07e46e99 100755 --- a/vc-utils/keymanager.sh +++ b/vc-utils/keymanager.sh @@ -281,7 +281,7 @@ graffiti-set() { echo "Please specify a graffiti string" exit 0 fi - if [[ ${#__graffiti} -gt 32 ]]; then + if [[ $(echo -n "${__graffiti}" | wc -c) -gt 32 ]]; then echo "The graffiti string cannot be longer than 32 characters. Emojis count as 4, each." exit 0 fi