fix: escape all $ for weebhook also

This commit is contained in:
Kay Marquardt (Gnadelwartz) 2021-02-17 08:49:39 +01:00
parent 8efbfcaab9
commit 3f848ac17d
3 changed files with 8 additions and 5 deletions

View File

@ -15,7 +15,7 @@ USAGE='process_update.sh [-h|--help] [debug] [<file]'
# AUTHOR: KayM (gnadelwartz), kay@rrr.de # AUTHOR: KayM (gnadelwartz), kay@rrr.de
# CREATED: 30.01.2021 19:14 # CREATED: 30.01.2021 19:14
# #
#### $$VERSION$$ v1.40-0-gf9dab50 #### $$VERSION$$ v1.45-dev-30-g8efbfca
#=============================================================================== #===============================================================================
#### ####
@ -34,6 +34,9 @@ print_help "${1:-nix}"
json='{"result": ['"$(cat)"']}' json='{"result": ['"$(cat)"']}'
UPDATE="$(${JSONSHFILE} -b -n <<<"${json}" 2>/dev/null)" UPDATE="$(${JSONSHFILE} -b -n <<<"${json}" 2>/dev/null)"
# escape bash $ expansion bug
UPDATE="${UPDATE//$/\\$}"
# assign to bashbot ARRAY # assign to bashbot ARRAY
Json2Array 'UPD' <<<"${UPDATE}" Json2Array 'UPD' <<<"${UPDATE}"

View File

@ -5,7 +5,7 @@
# This file is public domain in the USA and all free countries. # This file is public domain in the USA and all free countries.
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
# #
#### $$VERSION$$ v1.45-dev-29-gd6f37af #### $$VERSION$$ v1.45-dev-30-g8efbfca
# #
# source from commands.sh to use jsonDB functions # source from commands.sh to use jsonDB functions
# #

View File

@ -4,7 +4,7 @@
# File: processUpdates.sh # File: processUpdates.sh
# Note: DO NOT EDIT! this file will be overwritten on update # Note: DO NOT EDIT! this file will be overwritten on update
# #
#### $$VERSION$$ v1.45-dev-18-g193ca1e #### $$VERSION$$ v1.45-dev-30-g8efbfca
################################################################## ##################################################################
############## ##############
@ -47,6 +47,8 @@ delete_webhook() {
process_multi_updates() { process_multi_updates() {
local max num debug="$1" local max num debug="$1"
max="$(grep -F ',"update_id"]' <<< "${UPDATE}" | tail -1 | cut -d , -f 2 )" max="$(grep -F ',"update_id"]' <<< "${UPDATE}" | tail -1 | cut -d , -f 2 )"
# escape bash $ expansion bug
UPDATE="${UPDATE//$/\\$}"
Json2Array 'UPD' <<<"${UPDATE}" Json2Array 'UPD' <<<"${UPDATE}"
for ((num=0; num<=max; num++)); do for ((num=0; num<=max; num++)); do
process_update "${num}" "${debug}" process_update "${num}" "${debug}"
@ -345,8 +347,6 @@ get_updates(){
log_error "Recovered from timeout/broken/no connection, continue with telegram updates" log_error "Recovered from timeout/broken/no connection, continue with telegram updates"
# calculate next sleep interval # calculate next sleep interval
((nextsleep+= stepsleep , nextsleep= nextsleep>maxsleep ?maxsleep:nextsleep)) ((nextsleep+= stepsleep , nextsleep= nextsleep>maxsleep ?maxsleep:nextsleep))
# escape bash $ expansion bug
UPDATE="${UPDATE//$/\\$}"
# warn if webhook is set # warn if webhook is set
if grep -q '^\["error_code"\] 409' <<<"${UPDATE}"; then if grep -q '^\["error_code"\] 409' <<<"${UPDATE}"; then
[ "${OFFSET}" != "-999" ] && nextsleep="${stepsleep}" [ "${OFFSET}" != "-999" ] && nextsleep="${stepsleep}"