Repository navigation
Conversation
…tract_arguments
smart_split compared with `<`, so text whose length is an exact multiple of
chars_per_string went through the split path one last time on the remainder and
appended ''. smart_split("abc", 3) returned ["abc", ""], and sending that empty
part to Telegram fails with "message text is empty".
extract_arguments compiled its regexp and matched before looking at None, so a
non-text message raised TypeError on message.text. is_command and
extract_command already tolerate None, so this now matches them.
…lues
apply_html_entities formatted the date_time template with unix=, but the
template declares {unix_time}, so any message carrying a date_time entity
raised KeyError: 'unix_time' from .html_text. The entity was added in eternnoir#2570
and has never worked.
The text_link URL and the pre language were also interpolated raw. hlink and
hpre already escape both, so a URL or language containing a quote produced
broken HTML and could add attributes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Three bugs in
apply_html_entities, all in the sameformat_entitybranch.date_timeraises. The template declares{unix_time}, but the call formats it withunix=, so the lookup fails:This reaches users through
Message.html_text, so any message with adate_timeentity (added in #2570) crashes. It looks like the entity has never worked.text_linkURL is interpolated raw. A URL containing a quote produces broken HTML:prelanguage is interpolated raw. Same problem, and it can add attributes:hlinkandhprealready pass both throughescape_html, so this just makes the entity path consistent with them.Describe your tests
Added four tests to
tests/test_formatting.py, reusing theAttributeCollectorparser helper that is already there. They assert thedate_timeoutput exactly, and feed the link andpreoutput through an HTML parser to prove no extra attributes appear.The existing
test_apply_html_entitiesis an integration test that sends real messages, so it never runs without a bot token — these are the first unit tests for this function.Full suite:
317 passed, 73 skipped.Python version: 3.12.3
OS: macOS 27.2
Checklist: