Skip to content

Don't let protected messages be copied from the Translate window - #188

Open
null00x wants to merge 1 commit into
TelegramMessenger:masterfrom
null00x:fix/translate-copy-protected
Open

null00x wants to merge 1 commit into
TelegramMessenger:masterfrom
null00x:fix/translate-copy-protected

Conversation

@null00x

@null00x null00x commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Key change

In chats with saving content restricted, the Translate window no longer lets the text out. Before, the message menu hid Copy, but Translate was still offered, and its window had a Copy to Clipboard row and a copy button next to the translation, and both the original and the translated text could be selected or copied word by word from the right-click menu. Now, for a protected message, the window shows the translation without these controls, and the text can't be selected or copied. Translation itself still works, as on iOS.

Reason

The message menu hides Copy for protected messages (protected in ChatMessageMenuItems.swift), but the Translate item has no such check, and TranslateModalController didn't know about the protection.

The window now checks its message with the rule the menu uses (Message.isCopyProtected(cachedData:): the message's own protection flag, the chat's copy protection, the copyProtectionEnabled flags of a private chat, and self-destructing media). If the message is protected, or can't be found, TranslateModalController hides the Copy to Clipboard row and the copy button, and TranslateTableRowItem turns off selection and the text's right-click menu for both rows. Windows opened without a message (the input field, the AI editor) are unchanged.

iOS passes canCopy: !isCopyProtected to its translate screen (ChatInterfaceStateContextMenus.swift).

Steps in Telegram 13.1.0 (283357):

  1. In a channel with Restrict saving content, post a message in another language than the app's.
  2. Right-click it: there is no Copy, but there is Translate.
  3. Translate → Copy to Clipboard, then paste anywhere.

Screenshot/video result (before/after)

Before

The message menu has Translate but no Copy:
before_1_menu

The Translate window has Copy to Clipboard and a copy button:
before_2_translate

Copying works:
before_3_copied

The text is pasted into the input field:
before_4_pasted

After

The same message: the translation without copy controls:
after_1_translate

In a chat without restrictions, the controls are still there:
after_2_normal_chat

Confirmation

Tested on macOS 26.6.2 (25G83), Apple M3. Before: Telegram 13.1.0 (283357). After: local Debug build of this branch, based on 78be930.

  1. Channel with Restrict saving content → right-click a message → Translate. Expected: the translation is shown, with no Copy to Clipboard row and no copy button. Actual: as expected (before: both were there and copied the text).
  2. In the same window, select text or right-click a word. Expected: nothing is selected, no Copy item. Actual: as expected.
  3. Saved Messages → Translate. Expected: Copy to Clipboard and the copy button are there and work. Actual: as expected.

Limitations: tested only on macOS 26.6.2. For Articles, the copy button in a code block's header still copies the code, as it does in the chat itself for protected Articles; that is not changed here.

  • I confirm that I have tested the affected behavior and verified that it works properly, or verified the content and links for a documentation-only change.
The message menu hides Copy in chats with saving content restricted, but the
Translate window still offered Copy to Clipboard, a copy button, text
selection and a right-click Copy. For a copy-protected message, or one that
can't be found, the window now hides them and turns off selection and the
text menu.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant