feat(share): readable, unforgeable Telegram previews - #20
Merged
Conversation
The old preview was an unstructured wall of text, and Telegram auto-linkified URLs pulled from the index — a malicious link in someone else other transcript became tappable in the approval channel. Now every untrusted string (peer name, question, stated task, snippets) goes inside a code span or fence: markup renders literally, no auto-linking, and a snippet cannot fake our /ok footer. Layout is sectioned, fragments are capped per-chunk and overall with a count of what was withheld, and the /ok line is a code span so Telegram makes it tap-to-copy. Markdown send falls back to plain text if Telegram rejects the markup — a preview must never silently fail to arrive. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Максим посмотрел первое живое превью: «выглядит как пиздец какой-то». Он прав — и по дороге нашлась дыра посерьёзнее косметики.
Дыра: Telegram сам линкифицирует URL в тексте, а текст ответа приходит из индекса. То есть вредоносная ссылка из чужого транскрипта становилась нажимаемой прямо в канале апрува.
Решение — вся недоверенная строка живёт в коде: имя пира и короткие строки в inline-span, вопрос/задача/сниппеты в fence. Разметка рендерится буквально, автолинков нет, сниппет не может подделать нашу строку
/ok.Читаемость: секции вместо стены, кап на фрагмент (320) и на весь ответ (1400) со счётчиком «сколько ещё уйдёт при отправке», число фрагментов,
/ok <hash>как code span — Telegram делает его tap-to-copy.Отказоустойчивость: если Telegram отверг разметку — уходит plain-версия. Превью не имеет права молча не дойти.
Поймано вживую при первой отправке: незаэкранированная
(вfragment(s)роняла всё сообщение 400-й. Добавил тест, который проверяет, что в нашей собственной обвязке нет неэкранированных reserved-символов вне кода.11 новых тестов (14 в файле), сюита 224 passed.
🤖 Generated with Claude Code