Skip to content

fix(feishu): correct Chinese filename encoding in attachments#1834

Open
BingqingLyu wants to merge 1 commit into
mainfrom
fork-pr-59431-fix-issue-59409-v3
Open

fix(feishu): correct Chinese filename encoding in attachments#1834
BingqingLyu wants to merge 1 commit into
mainfrom
fork-pr-59431-fix-issue-59409-v3

Conversation

@BingqingLyu

@BingqingLyu BingqingLyu commented Apr 28, 2026

Copy link
Copy Markdown
Owner

Fixes openclaw#59409

Summary

When receiving files with Chinese filenames via Feishu webhook, the filenames were displayed as garbled text (Latin-1 decoded UTF-8 bytes).

Root Cause

  • HTTP headers are typically parsed as ISO-8859-1 (Latin-1)
  • UTF-8 encoded filenames get misinterpreted as Latin-1 characters
  • Example: 六大组件全解析.md shows as å_å_ç_ä_å_è_æ.md

Solution

  • Added fixMisdecodedUtf8() function to detect and correct the encoding
  • Re-encodes Latin-1 chars back to bytes and decodes as UTF-8
  • Applied to both Content-Disposition header and API response file_name field

Test Plan

  1. Send a file with Chinese filename via Feishu chat
  2. Check the saved file in ~/.openclaw/media/inbound/
  3. Verify filename is preserved correctly (e.g., 六大组件全解析---<uuid>.md)

🤖 Generated with ClawHub

Fixes openclaw#59409

When receiving files with Chinese filenames via Feishu webhook, the
filenames were displayed as garbled text (Latin-1 decoded UTF-8 bytes).

Root cause:
- HTTP headers are typically parsed as ISO-8859-1 (Latin-1)
- UTF-8 encoded filenames get misinterpreted as Latin-1 characters
- Example: "六大组件全解析.md" shows as "å_å_ç_ä_å_è_æ.md"

Solution:
- Added fixMisdecodedUtf8() function to detect and correct the encoding
- Re-encodes Latin-1 chars back to bytes and decodes as UTF-8
- Applied to both Content-Disposition header and API response file_name

The fix preserves valid Latin-1 strings and only corrects misdecoded UTF-8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Feishu plugin: Chinese filenames in attachments display as garbled (Latin-1 encoding issue)

2 participants