fix(feishu): recover UTF-8 filenames from Latin-1 encoded Content-Disposition#48578
Closed
alex-xuweilong wants to merge 1 commit intoopenclaw:mainfrom
Closed
fix(feishu): recover UTF-8 filenames from Latin-1 encoded Content-Disposition#48578alex-xuweilong wants to merge 1 commit intoopenclaw:mainfrom
alex-xuweilong wants to merge 1 commit intoopenclaw:mainfrom
Conversation
…position When the Feishu API returns Content-Disposition with filename="..." (without the RFC 5987 filename*=UTF-8'' form), the HTTP client may decode UTF-8 bytes as Latin-1, corrupting Chinese/CJK filenames (e.g. "何不同舟渡_2.txt" becomes "æµ_è_æ_ä_2.txt"). Add a tryRecoverLatin1AsUtf8 helper that detects high-byte Latin-1 artifacts and re-decodes them as UTF-8, applied to the plain filename="..." extraction path. Fixes openclaw#48388
Contributor
Greptile SummaryThis PR adds a small, targeted heuristic (
Confidence Score: 4/5
Last reviewed commit: cd566af |
Member
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.
Summary
Fixes garbled Chinese/CJK filenames when receiving files via Feishu channel.
Root Cause
When the Feishu API returns Content-Disposition with a plain filename header (without the RFC 5987 filename*=UTF-8'' form), the HTTP client decodes raw UTF-8 bytes as Latin-1. Each 3-byte CJK character becomes 3 Latin-1 characters, producing mojibake.
Fix
Add a tryRecoverLatin1AsUtf8() helper that detects high-byte Latin-1 artifacts and re-decodes them as UTF-8 via Buffer. Applied to the plain filename extraction path. Falls back to the original string if recovery fails.
Changes
Fixes #48388