Repository navigation
fix(dingtalk): transcode WebP attachments to PNG before upload - #241
Merged
Merged
Conversation
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.
What
DingTalk rejects WebP uploads: a WebP attachment failed at the upload stage with
40005 不合法的文件类型and was delivered to no target. DingTalk's media upload (docs) accepts only jpg/gif/png/bmp asimageand doc/docx/xls/xlsx/ppt/pptx/zip/pdf/rar asfile, so sending WebP as either type cannot work.The DingTalk sender now decodes a WebP attachment (by MIME type,
.webpname, or theRIFF…WEBPsignature) and uploads it as a real PNG named<name>.pngwithimage/png. The stored attachment is unchanged. Animated WebP sends its first frame. The 10 MiB attachment limit is checked before reading and again after conversion; decoding runs on a blocking thread with a 64 MiB allocation limit. A WebP that cannot be decoded fails in the prepare stage withDingTalk WebP decode failed, before any upload or message send.Attachment preparation moves out of
dingtalk_outbound.rsintodingtalk_outbound_attachment.rs. The only new dependency isimagewith thepngandwebpfeatures.Verification
send_attachmentspath, with only the external media upload faked:webp_attachment_is_sent_as_a_real_png_without_changing_the_source_blob: checks the PNG signature, the decoded 2x1 RGBA pixels including alpha,imagetype,overview.png,image/png, thesampleImageMsgpayload, and that the source blob is unchanged.invalid_webp_fails_before_upload_or_message_send.Both fail on the previous code and pass now; the existing DingTalk outbound tests still pass.
scripts/quality_gate.sh faston this branch: clippy, workspace tests, runtime tests, daemon nextest, doc tests and tooling all pass.