Commit d75fcc7
fix(bridge): convert <br> to newline for Telegram HTML mode (#23)
The Telegram Bot API's HTML parse mode does not support the <br> tag
and rejects it with "400 Bad Request: can't parse entities: Unsupported
start tag 'br'". Previously, markdownToHtml kept <br> in its whitelist,
so any CommonMark hard break (trailing two spaces or backslash) produced
by markdown-it would be forwarded to Telegram and crash the bridge with
an uncaught GrammyError.
Fix by replacing <br> with a literal newline before the whitelist strip,
and removing br from the whitelist comment/regex.
Repro: send any message whose markdown contains a hard line break, e.g.
"line one \nline two" — the bridge process exits with an unhandled
GrammyError in MessageRenderer.flushCallback.
Adds two regression tests covering both CommonMark hard break forms.
Co-authored-by: shu zf <shuzf@aicoda.tech>1 parent a69ed1c commit d75fcc7
2 files changed
Lines changed: 24 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
24 | 42 | | |
25 | 43 | | |
26 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
160 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
161 | 165 | | |
162 | 166 | | |
163 | 167 | | |
0 commit comments