Repository navigation
Detect keyboard stickers by image content instead of URI. - #15048
Open
actuallyrisk wants to merge 1 commit into
Open
actuallyrisk wants to merge 1 commit into
actuallyrisk wants to merge 1 commit into
Conversation
Since 7.41.0 an image committed by the keyboard is treated as a sticker only if its URI contains "sticker" or the SwiftKey share path. Keyboards that use other paths, such as Samsung Keyboard's Galaxy AI stickers (.../cache/temp_content/ai_expression/<id>.png), end up in the media editor and are sent as regular images with a bubble. Keep the URI check as a fast path and additionally treat an image as a sticker when it is at most 1024 px on the long side, roughly square (aspect ratio up to 1.5) and carries an alpha channel. The alpha check reads only the PNG IHDR/tRNS or WebP VP8X/VP8L header, so unlike the pre-7.41 pixel check it does not decode the image and cannot time out. GIFs are not inspected and keep relying on the URI fast path. Fixes signalapp#15035
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.
Since 7.41.0 an image committed by the keyboard is treated as a sticker only if its URI contains "sticker" or the SwiftKey share path. Keyboards that use other paths, such as Samsung Keyboard's Galaxy AI stickers (.../cache/temp_content/ai_expression/.png), end up in the media editor and are sent as regular images with a bubble.
Keep the URI check as a fast path and additionally treat an image as a sticker when it is at most 1024 px on the long side, roughly square (aspect ratio up to 1.5) and carries an alpha channel. The alpha check reads only the PNG IHDR/tRNS or WebP VP8X/VP8L header, so unlike the pre-7.41 pixel check it does not decode the image and cannot time out. GIFs are not inspected and keep relying on the URI fast path.
Fixes #15035
First time contributor checklist
Contributor checklist
Fixes #15035syntaxDescription
Since 7.41.0 (2e50699) an image committed by the keyboard is a sticker only if its URI contains
stickeror the SwiftKey share path. Samsung Keyboard commits its Galaxy AI stickers ascontent://com.samsung.android.honeyboard.provider/root/storage/emulated/0/Android/data/com.samsung.android.honeyboard/cache/temp_content/ai_expression/<millis>.png, so they open the media editor and are sent as regular images with a bubble (#15035).Rather than adding one URI pattern per keyboard, this keeps the URI check as a fast path and additionally treats an image as a sticker when it is at most 1024 px on the long side, has an aspect ratio of at most 1.5 and carries an alpha channel. The alpha check (
ImageAlphaSniffer) reads only the PNG IHDR/tRNS or WebP VP8X/VP8L header: a few bytes, no decoding, nothing that can time out like the pre-7.41 Glide pixel check. GIFs are not inspected and keep relying on the URI fast path. Only the sending client changes, the borderless flag already travels in the message.Trade-off: a small transparent PNG from the keyboard's clipboard is also sent borderless and skips the editor.
Testing
ImageAlphaSnifferTest, 23 cases: all PNG color types, tRNS after PLTE/gAMA/large metadata chunks and beyond the 64 KiB scan limit, VP8X/VP8L/VP8 headers, truncated and non-image input, PNGs encoded by ImageIO. ktlint 1.5.0 clean.adb shell dumpsys activity -p org.thoughtcrime.securesms permissions.