Commit 6b3946f
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 6b3946f
3 files changed
Lines changed: 78 additions & 18 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 | + | |
| 445 | + | |
437 | 446 | | |
438 | 447 | | |
439 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
220 | | - | |
221 | | - | |
| 219 | + | |
222 | 220 | | |
223 | 221 | | |
224 | 222 | | |
| |||
235 | 233 | | |
236 | 234 | | |
237 | 235 | | |
238 | | - | |
| 236 | + | |
239 | 237 | | |
240 | 238 | | |
241 | 239 | | |
242 | 240 | | |
243 | 241 | | |
244 | 242 | | |
245 | | - | |
| 243 | + | |
246 | 244 | | |
247 | 245 | | |
248 | 246 | | |
| |||
255 | 253 | | |
256 | 254 | | |
257 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
258 | 273 | | |
259 | 274 | | |
260 | 275 | | |
| |||
271 | 286 | | |
272 | 287 | | |
273 | 288 | | |
274 | | - | |
275 | | - | |
276 | | - | |
| 289 | + | |
277 | 290 | | |
278 | 291 | | |
279 | 292 | | |
| |||
293 | 306 | | |
294 | 307 | | |
295 | 308 | | |
| 309 | + | |
296 | 310 | | |
297 | | - | |
| 311 | + | |
298 | 312 | | |
299 | 313 | | |
300 | 314 | | |
301 | 315 | | |
302 | 316 | | |
303 | 317 | | |
304 | 318 | | |
305 | | - | |
| 319 | + | |
306 | 320 | | |
307 | 321 | | |
308 | 322 | | |
309 | 323 | | |
310 | 324 | | |
311 | 325 | | |
312 | | - | |
| 326 | + | |
313 | 327 | | |
314 | 328 | | |
315 | | - | |
| 329 | + | |
316 | 330 | | |
317 | 331 | | |
318 | | - | |
| 332 | + | |
319 | 333 | | |
320 | 334 | | |
321 | | - | |
| 335 | + | |
322 | 336 | | |
323 | 337 | | |
324 | 338 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | | - | |
| 472 | + | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | 476 | | |
477 | | - | |
478 | | - | |
| 477 | + | |
| 478 | + | |
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
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 | + | |
| 522 | + | |
486 | 523 | | |
487 | 524 | | |
488 | 525 | | |
| |||
0 commit comments