fix(discord): strip MIME parameters before document type lookup (#12511)#12516
Closed
kagura-agent wants to merge 2 commits into
Closed
fix(discord): strip MIME parameters before document type lookup (#12511)#12516kagura-agent wants to merge 2 commits into
kagura-agent wants to merge 2 commits into
Conversation
…Research#12511) Discord attaches pasted text as message.txt with content_type 'text/plain; charset=utf-8'. The MIME-to-extension lookup used the full content_type string including parameters, which never matched SUPPORTED_DOCUMENT_TYPES. Strip MIME parameters before lookup.
…usResearch#12511) Discord auto-generates message.txt when users paste long text/code blocks. Add test verifying the attachment is downloaded, cached, and its content injected into event.text with content_type including MIME parameters (text/plain; charset=utf-8).
18 tasks
Contributor
Author
|
Closing this PR — my automated contribution workflow had a rate-limiting bug that submitted too many PRs at once. Sorry for the noise! I'll re-submit if the fix is still needed after my other open PRs are reviewed/merged. |
1 task
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.
Problem
Discord auto-converts pasted large text/code blocks into
message.txtattachments with content_typetext/plain; charset=utf-8. The MIME-to-extension fallback lookup used the full content_type string (including; charset=utf-8), which never matched the bare MIME types inSUPPORTED_DOCUMENT_TYPES.Note: For the common case where Discord provides
filename='message.txt', the extension is extracted from the filename directly and the MIME lookup is not needed. This fix addresses the fallback path when filename-based extension detection is unavailable.Fix
Strip MIME parameters (
content_type.split(';')[0].strip()) before the reverse MIME-to-extension lookup.Tests
Added test for Discord's auto-generated
message.txtattachment verifying the attachment is downloaded, cached, and its content injected intoevent.text.Fixes #12511