Skip to content

TelegramBotHandler: API returns error when truncating/splitting in HTML parse mode #1990

@MacDada

Description

@MacDada

Monolog 3.9

I set $parseMode to 'HTML' and keep the default $splitLongMessages as false.

When the message is looooong, it gets truncated. If the truncation happens inside HTML tag,
the Telegram API returns error 400:

Bad Request: can't parse entities: Can't find end tag corresponding to start tag "code"

In my example the loooong string has <code>blah blah</code>. Lets say it gets truncated at first blah, then the </code> is gone and API complains.

  • Possible solution 1: would need to fix (actually parse?) HTML if truncating?
  • Possible solution 2: strip HTML tags when truncating? (kinda ugly)
  • Low hanging fruit: at least want about that in the (php) docs?

EDIT: actually, with $splitLongMessages=true same kind of problem – the message splits inside HTML causing Telegram API error(s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions