Commit 56f3500
committed
fix(telegram): stop auto-linking destinations in /policy show
Telegram was rendering every destination string in /policy show output
as a clickable blue link (example.com, api.github.com, etc.) because
the message was sent in plain text mode and Telegram auto-detects URL
patterns.
Wrap the output in <pre>...</pre> and send with ParseMode=HTML +
DisableWebPagePreview. Inside a preformatted block Telegram leaves URL
patterns alone, and the monospace rendering also aligns the columns
better.
- commands.go: htmlPreOpen/htmlPreClose constants, htmlEscapeText
helper, wrap both policyShow (engine fallback) and
policyShowFromStore in <pre>. Escape destination, tool, pattern,
replacement, name, source, default verdict, and protocols.
- approval.go: sendReply path sniffs the <pre> prefix and switches to
HTML parse mode with web-page preview disabled. Other replies are
still plain text.
- Tests: TestPolicyShowEscapesHTML and a wrapping check in
TestPolicyShowIncludesAllFields.1 parent b519e2c commit 56f3500
3 files changed
Lines changed: 79 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
437 | 445 | | |
438 | 446 | | |
439 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
219 | 220 | | |
220 | | - | |
| 221 | + | |
221 | 222 | | |
222 | 223 | | |
223 | 224 | | |
| |||
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
238 | | - | |
| 239 | + | |
239 | 240 | | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
245 | | - | |
| 246 | + | |
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
| |||
252 | 253 | | |
253 | 254 | | |
254 | 255 | | |
| 256 | + | |
255 | 257 | | |
256 | 258 | | |
257 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
258 | 282 | | |
259 | 283 | | |
260 | 284 | | |
| |||
271 | 295 | | |
272 | 296 | | |
273 | 297 | | |
| 298 | + | |
274 | 299 | | |
275 | | - | |
| 300 | + | |
276 | 301 | | |
277 | 302 | | |
278 | 303 | | |
| |||
302 | 327 | | |
303 | 328 | | |
304 | 329 | | |
305 | | - | |
| 330 | + | |
306 | 331 | | |
307 | 332 | | |
308 | 333 | | |
309 | 334 | | |
310 | 335 | | |
311 | 336 | | |
312 | | - | |
| 337 | + | |
313 | 338 | | |
314 | 339 | | |
315 | | - | |
| 340 | + | |
316 | 341 | | |
317 | 342 | | |
318 | | - | |
| 343 | + | |
319 | 344 | | |
320 | 345 | | |
321 | | - | |
| 346 | + | |
322 | 347 | | |
323 | 348 | | |
324 | 349 | | |
| |||
328 | 353 | | |
329 | 354 | | |
330 | 355 | | |
| 356 | + | |
331 | 357 | | |
332 | 358 | | |
333 | 359 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
486 | 522 | | |
487 | 523 | | |
488 | 524 | | |
| |||
0 commit comments