Skip to content

Commit

Permalink
Better graffiti input check (#1730)
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne authored Feb 5, 2024
1 parent 0a7b1fc commit cbc0b24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion ethd
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}

Expand Down
2 changes: 1 addition & 1 deletion vc-utils/keymanager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cbc0b24

Please sign in to comment.