mirror of
https://github.com/anten-ka/gotelegram_pro.git
synced 2026-05-19 13:26:02 +00:00
fix(v2.4.2): iter2 audit fixes
- bot.py: safe_edit_message now accepts disable_web_page_preview (CRIT: was TypeError in cb_pro_confirm success path)
- bot.py: status display uses template_id field (was 'template' — mismatch with save_gotelegram_config, template never showed)
- bot.py: cb_pro_confirm validates tpl_id against [A-Za-z0-9_-]{1,64} before subprocess (defense-in-depth)
- bot.py: cb_lite_domain validates domain shape
- bot.py: asyncio.Lock _BOT_ACTION_LOCK serializes concurrent change-template/change-lite-domain calls
- install.sh: bot_update_config_field uses shell `date -Iseconds` instead of jq's `now|todate` (jq 1.5 compat for Debian 10)
This commit is contained in:
11
install.sh
11
install.sh
@@ -1168,17 +1168,20 @@ bot_emit_json() {
|
||||
printf '{"status":"%s","message":"%s"%s}\n' "$status" "$msg_esc" "$extra"
|
||||
}
|
||||
|
||||
# Update a single key in config.json without rewriting the whole file
|
||||
# Update a single key in config.json without rewriting the whole file.
|
||||
# Uses `date -Iseconds` rather than jq's `now | todate` — the latter requires
|
||||
# jq 1.6+ which is not available on Debian 10 or older CentOS.
|
||||
bot_update_config_field() {
|
||||
local key="$1"
|
||||
local value="$2"
|
||||
if [ ! -f "$GOTELEGRAM_CONFIG" ]; then
|
||||
return 1
|
||||
fi
|
||||
local tmp
|
||||
local tmp now
|
||||
tmp=$(mktemp) || return 1
|
||||
if jq --arg k "$key" --arg v "$value" \
|
||||
'.[$k] = $v | .updated_at = (now | todate)' \
|
||||
now=$(date -Iseconds 2>/dev/null || date +%Y-%m-%dT%H:%M:%S%z)
|
||||
if jq --arg k "$key" --arg v "$value" --arg t "$now" \
|
||||
'.[$k] = $v | .updated_at = $t' \
|
||||
"$GOTELEGRAM_CONFIG" > "$tmp" 2>/dev/null; then
|
||||
mv "$tmp" "$GOTELEGRAM_CONFIG"
|
||||
chmod 600 "$GOTELEGRAM_CONFIG"
|
||||
|
||||
Reference in New Issue
Block a user