Don't hand WebKitGTK a paste of an empty clipboard #18
Closed
asxpi
wants to merge 0 commits from
asxpi/anotherim-js:fix/empty-paste into develop
pull from: asxpi/anotherim-js:fix/empty-paste
merge into: another-im:develop
another-im:develop
another-im:fix/relock-dismiss
another-im:fix/settings-accounts
another-im:feat/unified-dialogs-1
another-im:feat/unified-dialogs-2
another-im:feat/unified-dialogs-3
another-im:feat/one-status
another-im:macos-0.6.1
another-im:fix/console-tab-out
another-im:fix/desktop-drop
another-im:fix/xml-console-menu
another-im:feat/telegram-connect
another-im:feat/chat-tags
another-im:feat/muc-omemo
another-im:integrate/origin-develop-2026-10-02
another-im:fix/media-bubble-size
another-im:fix/empty-click-focus
another-im:feat/system-font-default
another-im:integrate/develop-2026-10-02
another-im:fix/attachment-decrypt
another-im:feat/system-font
another-im:fix/chat-links
another-im:fix/android-background-network
another-im:feat/tray
another-im:feat/thumb-cache
another-im:fix/android-csi-native
another-im:feat/opfs-store
another-im:fix/alttab-focus
another-im:try/groupcalls
another-im:feat/pwa-install
another-im:integrate/0.3.0
another-im:fix/upload-bubble-030
another-im:feat/drag-select
another-im:fix/upload-bubble
another-im:feat/encryption-info
another-im:chore/libtacky-path
another-im:feat/chat-header-menus
another-im:integrate/develop
another-im:fix/saved-top-linux-voice
another-im:fix/dialog-close-icons
another-im:feat/window-title-unread
another-im:feat/groupcalls
another-im:fix/open-picture-one-tap
another-im:feat/server-info-console
another-im:fix/chat-open-scroll-end
another-im:fix/desktop-push-mutes
another-im:fix/android-mute-push-selection
another-im:feat/otr-lock-colours
another-im:otr-v3-secret-chats
another-im:chore/remove-otr
another-im:feat/room-invites
another-im:feat/voice-video-messages
another-im:docs/readme
another-im:fix/android-empty-files
another-im:api-freeze
another-im:feat/push-counts
another-im:feat/h264-android-save
another-im:feat/keep-attachments-decrypted
another-im:feat/media-player
another-im:feat/fix-subdomain-attachments
another-im:feat/fonts-pt-sans
another-im:feat/always-decrypt-on-the-fly
another-im:feat/default-scale-125
another-im:fix/composer-focus-after-send
another-im:feat/android-native-calls
another-im:feat/media-stream-decrypt
another-im:feat/download-failure
another-im:feat/outbox-cap
another-im:feat/web-call-sheet
another-im:feat/first-run-push-check
another-im:feat/font-size-110
another-im:feat/log-view
another-im:fix/failed-transfer-history
another-im:feat/secure-unlock
another-im:feat/tpm-desktop
another-im:feat/tpm-android
another-im:feat/api-freeze-client
No reviewers
Labels
Clear labels
bug
Something is not working
duplicate
This issue or pull request already exists
feature request
New feature
linux
linux exclusive
macos
macos exclusive
needsinfo
Needs more information
severity: high
Major issue, significantly impacts usability or blocks core functionality
severity: low
Minor issue, cosmetic or rarely affects usage
severity: medium
Noticeable issue, but there is a workaround or limited impact
telegram_gw
issues related to the telegram gw
ui/ux
issues related to the interface and user experience (visual glitches, layout, interactions, usability problems)
windows
windows exclusive
wontfix
This won't be fixed
No labels
bug
duplicate
feature request
linux
macos
needsinfo
severity: high
severity: low
severity: medium
telegram_gw
ui/ux
windows
wontfix
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
another-im/anotherim-js!18
Loading…
Reference in a new issue
No description provided.
Delete branch "asxpi/anotherim-js:fix/empty-paste"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The bug. The desktop app on Linux (GTK 3 WebKitGTK, 2.54.1 in the GNOME 50 runtime) crashes with SIGSEGV on Ctrl+V or Shift+Insert when the clipboard is empty. On Wayland that means nothing has been copied since login, or the app that copied has quit. Reproduce with
wl-copy --clearand then a paste in the chat. Symbolized:GTK 3 reports a clipboard without targets as
atoms == NULL,n_atoms == -1. A loop that ran zero times was turned into a span by WebKit's 308123@main, and the span takes -1 as its size. It's WebKit's bug: bugs.webkit.org 324466, with a fix in WebKit PR #77266. Until a fixed WebKitGTK reaches the Flatpak runtime, the app needs to work around it.The change.
no_empty_paste(window), next tono_pinch_zoominpage_window_made:gtk_clipboard_request_targetsWebKit uses, through a callback that handles -1, when the window is made and on the clipboard'sowner-change(connected by name, since gtk-rs 0.18 doesn't bind it). Asking synchronously at the key would run a nested main loop in the handler.key-press-eventswallows Ctrl+V and Shift+Insert while the flag is set. Pasting nothing does nothing anyway.Once a fixed WebKitGTK ships it can go.
Checked in a local Flatpak build of 0.5.7 with this change, on GNOME 50 (Wayland): pasting an empty clipboard no longer crashes, and there was no core dump over a 15-minute session.
🤖 Generated with Claude Code
Merged into develop by hand as
899719b4(2026-10-16), for 0.5.9. The approach is right and the review found one gap, fixed on top inbb88d923: the guard matched the paste by keyval, so on a layout whose V key gives another letter (Cyrillic em, say) Ctrl+V was not recognised while WebKit still took it as a paste by the key's Latin level, and the crash stayed for those users; the handler now also looks the hardware keycode up in the display's keymap and takes any group's v or V. Two notes, not changed: the PRIMARY-selection middle-click paste and WebKit's context-menu Paste are not covered, and between an owner-change and the targets answer the flag can be a few ms stale. Thank you.Pull request closed