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.
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
Two input-handling bugs in
telebot/util.py.smart_splitappends an empty part. It compared with<, so any text whose length is an exact multiple ofchars_per_stringwent through the split path one last time on the remainder and appended'':Sending that empty part to Telegram fails with
Bad Request: message text is empty. Changed to<=, which covers every multiple, not just the 4096 case.extract_argumentsraises onNone. It compiled the regexp and matched before checking the argument, so a non-text message (message.text is None) raisedTypeError.is_commandandextract_commandalready tolerateNone, so this now matches them.Describe your tests
Added
tests/test_util.py—smart_splithad no coverage at all. It walks exact multiples across several chunk sizes, checks the newline/space preference, the 4096 cap, and theNonehandling plus the normalextract_argumentscases.Full suite:
314 passed, 73 skipped.Python version: 3.12.3
OS: macOS 27.2
Checklist: