media: add shared filename decoder#71517
Conversation
cf186c2 to
4fadbb9
Compare
Greptile SummaryThis PR adds a shared
Confidence Score: 3/5Not safe to merge without addressing the missing path-sanitisation in A P1 security-relevant finding (path traversal not sanitised in Feishu inbound filenames) prevents a high-confidence score. The core
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4fadbb92e7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
4fadbb9 to
0be9dc7
Compare
|
Codex review: needs real behavior proof before merge. Reviewed July 3, 2026, 5:52 AM ET / 09:52 UTC. Summary PR surface: Source +280, Tests +111. Total +391 across 6 files. Reproducibility: yes. by source inspection: current main's remote media parser cannot decode the PR's multi-charset Content-Disposition cases, and Feishu filename selection still has paths outside the PR's bot-content normalization. I did not run tests because this review is read-only. Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Refresh against current main, put the decoder in the media-core/plugin-safe boundary, wire both remote media and Feishu metadata/fallback filename paths through one helper, and add redacted terminal or live Feishu-path proof. Do we have a high-confidence way to reproduce the issue? Yes, by source inspection: current main's remote media parser cannot decode the PR's multi-charset Content-Disposition cases, and Feishu filename selection still has paths outside the PR's bot-content normalization. I did not run tests because this review is read-only. Is this the best way to solve the issue? No. The direction is useful, but on current main the best fix is a media-core/plugin-safe shared helper plus Feishu metadata-path wiring, not a new src/media helper with duplicated Feishu recovery logic. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 36dd9ee3c3c1. Label changesLabel justifications:
Evidence reviewedPR surface: Source +280, Tests +111. Total +391 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Status update after addressing automated review feedback: This PR is intended as the first scoped fix for #48788, plus the related #48388 filename decoding behavior. It fixes the shared media download path and Feishu inbound filename handling without trying to migrate every remaining channel-specific filename path in one PR. What was fixed in the latest pushed head:
Verification run locally before push:
Remaining scope: #48788 should stay open after this PR unless maintainers want to expand this change. Remaining channel filename migrations and any broader SDK/API documentation or baseline alignment can be handled as follow-up work under #48788. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
0be9dc7 to
9c2a800
Compare
|
Heads up: this PR needs to be updated against current |
|
This pull request has been automatically marked as stale due to inactivity. |
|
@szupzj18 thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: media: add shared filename decoder This is item 1/1 in the current shard. Shard 5/22. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Summary
Content-Dispositionedge cases and Feishu mojibake fixes are easy to miss or duplicate.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Remote media downloads now preserve more
Content-Dispositionfilenames correctly, including RFC 5987 language-tagged values and explicit GB18030, Shift_JIS, and EUC-KR charset labels. Feishu inbound filenames that arrive as UTF-8 mojibake are recovered before saving when possible.Security Impact (required)
Repro + Verification
Environment
Steps
Content-Dispositionfilenames with language tags and explicit charset labels.Expected
saveMediaBufferreceives the filename.Actual
Matches expected in targeted tests.
Evidence
Targeted verification:
corepack pnpm tsgowas also run. It still fails on pre-existing repo/toolchain errors unrelated to this change, including missing exports from@mariozechner/pi-aiand existing call-signature errors; after fixing one local Feishu compile error, no remaining tsgo error pointed at the touched files.Human Verification (required)
filename*priority, language tags, GB18030 / Shift_JIS / EUC-KR decoding, Windows path basename reduction, Latin-1/Windows-1252 mojibake recovery, remote media fetch integration../..rejection, normal Latin-1 text fallback.Review Conversations
Compatibility / Migration
Failure Recovery (if this breaks)
src/media/filename.ts,src/media/fetch.ts,src/plugin-sdk/feishu.ts,extensions/feishu/src/bot.ts, and related tests.Risks and Mitigations
Real behavior proof
node --import tsx --input-type=moduleimportingsrc/media/filename.tsandsrc/media/fetch.ts, constructing a realResponse, and callingsaveResponseMedia.{ "rfc5987Decoded": "✓-report.txt", "mojibakeDecoded": "中国银行.pdf", "savedFileName": "photo.txt", "savedContentType": "text/plain", "savedBytes": 2 }✓-report.txt, the mojibake filename recovered to中国银行.pdf, and the response save path reducedC:\temp\photo.txttophoto.txtwhile preservingtext/plaincontent.