Skip to content

Commit 65ad3c8

Browse files
committed
Fix Telegram messages: expand literal \n to real newlines before sending
In bash, \n in double-quoted strings is literal backslash+n, not a newline character. curl --data-urlencode sends them as %5Cn and Telegram renders them literally in message text, causing \n\n to appear visibly around proxy links. Fix: run msg through printf '%b' in telegram_send_message() and tg_send() to convert \n to actual newlines (0x0A) before the string is URL-encoded and sent to the Telegram API. Validated: _esc() markdown escapes (\_, \*) are unaffected since underscore and asterisk are not printf escape sequences.
1 parent fd38e1f commit 65ad3c8

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

mtproxymax.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2618,7 +2618,8 @@ self_update() {
26182618
# ── Section 14: Telegram Integration ────────────────────────
26192619

26202620
telegram_send_message() {
2621-
local msg="$1"
2621+
local msg
2622+
msg=$(printf '%b' "$1") # expand literal \n to real newlines
26222623
local token="${TELEGRAM_BOT_TOKEN}"
26232624
local chat_id="${TELEGRAM_CHAT_ID}"
26242625

@@ -2927,7 +2928,8 @@ get_cached_ip() {
29272928
29282929
# Minimal Telegram send
29292930
tg_send() {
2930-
local msg="$1"
2931+
local msg
2932+
msg=$(printf '%b' "$1") # expand literal \n to real newlines
29312933
local label="${TELEGRAM_SERVER_LABEL:-MTProxyMax}"
29322934
local _ip; _ip=$(get_cached_ip)
29332935
[ -n "$_ip" ] && msg="[$(_esc "$label") | ${_ip}] ${msg}" || msg="[$(_esc "$label")] ${msg}"

0 commit comments

Comments
 (0)