From 805e220f4308309007a450148a95b3517f287d7b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 29 Jul 2021 17:37:38 +0200 Subject: [PATCH] bugfix: avoid octal interpretation of leading zeros --- newdate.sh | 6 +++--- widgets.sh | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/newdate.sh b/newdate.sh index 4b220c1..74277dc 100755 --- a/newdate.sh +++ b/newdate.sh @@ -59,8 +59,8 @@ fs_splittimes() { pattern="^(0?\[0-9\]|1\[0-9\]|2\[0-3\]):(\[0-5\]\[0-9\])$"/> - [submit "todremove" "%i" -] - ' "$day" "${time%-*}" "$day" "${time#*-}" "${c}" + [submit "todremove_%s" "%i" -] + ' "$day" "${time%-*}" "$day" "${time#*-}" "$day" "${c}" done printf '[submit "addtime" "%s" + Add Time Option]' "$day" done) @@ -111,7 +111,7 @@ if [ "$REQUEST_METHOD" = POST ]; then [ "${todstart%:??}" -lt "${todend%:??}" -o "${todstart%:??}" -eq "${todend%:??}" -a "${todstart#*:}" -lt "${todend#*:}" ] \ 2>&- \ && { printf '%02i:%02i-%02i:%02i\n' "${todstart%:??}" "${todstart#*:}" "${todend%:??}" "${todend#*:}"; }\ - || { [ "${todstart%:??}" -ge 0 -a "${todstart#*:}" -ge 0 ] 2>&- && printf '%02i:%02i-\n' "${todstart%:??}" "${todstart#*:}"; } + || { [ "${todstart%:??}" -ge 0 -a "${todstart#*:}" -ge 0 ] 2>&- && printf '%02i:%02i-\n' $(dec ${todstart%:??} ${todstart#*:}); } done |grep -xE '^([01][0-9]|2[0-3]):([0-5][0-9])-(([01][0-9]|2[0-3]):([0-5][0-9]))?$' |sort -u )" [ "$addtime" = "$date" ] && DBM "$file" append "tod_${date}" "${BR}-" diff --git a/widgets.sh b/widgets.sh index 3eb4850..835e646 100755 --- a/widgets.sh +++ b/widgets.sh @@ -7,6 +7,14 @@ else markdown() { busybox awk -f "$_EXEC/cgilite/markdown.awk"; } fi +dec(){ + local n + for n in "$@"; do + while [ "${n}" != "${n#0}" ]; do n="${n#0}"; done + printf %i\\n "$n" + done +} + checked(){ local check="$1"; shift 1; for comp in "$@"; do -- 2.39.2