Skip to content

Commit 3f848ac

Browse files
committed
fix: escape all $ for weebhook also
1 parent 8efbfca commit 3f848ac

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

bin/process_update.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ USAGE='process_update.sh [-h|--help] [debug] [<file]'
1515
# AUTHOR: KayM (gnadelwartz), [email protected]
1616
# CREATED: 30.01.2021 19:14
1717
#
18-
#### $$VERSION$$ v1.40-0-gf9dab50
18+
#### $$VERSION$$ v1.45-dev-30-g8efbfca
1919
#===============================================================================
2020

2121
####
@@ -34,6 +34,9 @@ print_help "${1:-nix}"
3434
json='{"result": ['"$(cat)"']}'
3535
UPDATE="$(${JSONSHFILE} -b -n <<<"${json}" 2>/dev/null)"
3636

37+
# escape bash $ expansion bug
38+
UPDATE="${UPDATE//$/\\$}"
39+
3740
# assign to bashbot ARRAY
3841
Json2Array 'UPD' <<<"${UPDATE}"
3942

modules/jsonDB.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# This file is public domain in the USA and all free countries.
66
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
77
#
8-
#### $$VERSION$$ v1.45-dev-29-gd6f37af
8+
#### $$VERSION$$ v1.45-dev-30-g8efbfca
99
#
1010
# source from commands.sh to use jsonDB functions
1111
#

modules/processUpdates.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# File: processUpdates.sh
55
# Note: DO NOT EDIT! this file will be overwritten on update
66
#
7-
#### $$VERSION$$ v1.45-dev-18-g193ca1e
7+
#### $$VERSION$$ v1.45-dev-30-g8efbfca
88
##################################################################
99

1010
##############
@@ -47,6 +47,8 @@ delete_webhook() {
4747
process_multi_updates() {
4848
local max num debug="$1"
4949
max="$(grep -F ',"update_id"]' <<< "${UPDATE}" | tail -1 | cut -d , -f 2 )"
50+
# escape bash $ expansion bug
51+
UPDATE="${UPDATE//$/\\$}"
5052
Json2Array 'UPD' <<<"${UPDATE}"
5153
for ((num=0; num<=max; num++)); do
5254
process_update "${num}" "${debug}"
@@ -345,8 +347,6 @@ get_updates(){
345347
log_error "Recovered from timeout/broken/no connection, continue with telegram updates"
346348
# calculate next sleep interval
347349
((nextsleep+= stepsleep , nextsleep= nextsleep>maxsleep ?maxsleep:nextsleep))
348-
# escape bash $ expansion bug
349-
UPDATE="${UPDATE//$/\\$}"
350350
# warn if webhook is set
351351
if grep -q '^\["error_code"\] 409' <<<"${UPDATE}"; then
352352
[ "${OFFSET}" != "-999" ] && nextsleep="${stepsleep}"

0 commit comments

Comments
 (0)