Fix create_deep_linked_url accepting 4-character bot usernames - #5325
Open
Sanjays2402 wants to merge 1 commit into
Open
Fix create_deep_linked_url accepting 4-character bot usernames#5325Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
create_deep_linked_url validated bot_username with len(bot_username) <= 3, so a 4-character username was accepted and produced a URL Telegram cannot resolve. Telegram requires usernames to be 5-32 characters, so the guard now rejects anything shorter than 5 characters and the docstring states the correct minimum. Updated the existing too-short-username assertion in tests/test_helpers.py to use a 4-character name, which fails without the fix and passes with it. Closes python-telegram-bot#5284
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.
Closes #5284
create_deep_linked_urlguardedbot_usernamewithlen(bot_username) <= 3, so a 4-character username was accepted and produced a URL Telegram cannot resolve; Telegram requires usernames to be 5-32 characters. The guard now rejects anything under 5 characters, and the docstring states the correct minimum.Per @harshil21's review on the earlier #5285, I kept a single test: the existing too-short-username assertion in
tests/test_helpers.pynow uses a 4-character name. It fails without the source change (DID NOT RAISE ValueError) and passes with it;tests/test_helpers.pyis 183 passed, ruff check and format clean.I did not add the
changes/unreleased/*.tomlchango fragment — happy to push it, or it can be added with the suggested wording:bugfixes = "Fixed ``create_deep_linked_url`` silently accepting 4-character bot usernames".This change was prepared with AI assistance; the regression test was run locally and fails without the fix.