Repository navigation
Fix UTF-16 rendering crashes and validate REST API requests - #6
Merged
fdciabdul merged 2 commits intoNov 1, 2026
Merged
Conversation
Map Telegram entity offsets to rune boundaries for Markdown and ANSI rendering. Skip invalid spans and preserve the body once when formatting overlaps, preventing slice-bounds panics on messages containing emoji. Add regression cases for supplementary Unicode, invalid ranges, and preservation of message text.
Truncate shared REST/MCP previews on Unicode character boundaries. Reject malformed or overflowing numeric query parameters and trailing JSON data before invoking Telegram operations. Add regression tests and document the API validation rules and interactive login flow.
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.
Opening a chat containing formatted text after emoji can crash the TUI with a slice-bounds panic. Telegram entity offsets count UTF-16 code units, but the Markdown and ANSI renderers used them directly as rune indexes.
This PR converts entity ranges to rune boundaries before slicing and skips nil, invalid, overflowing, or split-surrogate ranges. The flat renderers retain enclosing formatting for overlapping ranges so message text is emitted once.
It also fixes issues found while exercising the REST API:
Regression tests cover supplementary Unicode characters, malformed and overlapping entity ranges, preview boundaries, service messages, JSON round trips, numeric overflow, and trailing request data.
Validation:
go test -p=1 ./...go vet -p=1 ./...gofmt -l .(no output)limit=4294967297request silently returned one message; the fixed API returns HTTP 400. Send/edit operations were validated with local tests.