fix(files): keep file extensions on extensionless downloads - #7573
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR preserves MIME-derived extensions when extensionless files are fetched, served individually, or placed into ZIP archives.
Confidence Score: 5/5The PR appears safe to merge with no outstanding correctness, security, or repository-rule issues. The follow-up replaces the capped extension regex with the repository’s existing alphanumeric-extension predicate, preserving long extensions while retaining the intended behavior for punctuation-bearing page names. The previous finding was fully addressed and its thread was resolved.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/uploads/utils/file-utils.ts | Adds shared MIME-derived extension handling and fixes extension detection without imposing a length cap. |
| apps/sim/app/api/files/utils.ts | Uses the shared helper when deriving single-file response names before secure disposition selection. |
| apps/sim/lib/uploads/contexts/workspace/fetch-external-url.ts | Adds a MIME-derived extension to extensionless URL path names before workspace upload. |
| apps/sim/lib/uploads/zip-entry-path.ts | Adds missing MIME-derived extensions before ZIP-path sanitization and collision handling. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Stored or fetched filename] --> B{Alphanumeric extension exists?}
B -- Yes --> C[Preserve filename]
B -- No --> D[Map content type to extension]
D --> E[Append mapped extension]
C --> F[Single-file response or ZIP entry]
E --> F
Reviews (2): Last reviewed commit: "fix(files): detect extensions without a ..." | Re-trigger Greptile
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
<name>in the Files UI, or a URL fetch whose path ends in a baredownloadsegment) downloaded with no extension, so the saved image could not be opened until one was added by handensureFileNameExtensionand apply it to zip entry paths (internal + v2 bulk download, Chat compress), tocreateFileResponsefor single-file downloads (generalizes the existing Sim-page.htmlre-append), and to the URL-fetch save path so new files are stored with an extensiongetExtensionFromMimeTypenow ignores content-type parameters such as; charset=utf-8Follow-ups, out of scope here: the markdown export's embedded-asset zip and the v1/v2 single-file routes build their own
Content-Dispositionand still emit the extensionless name; the Chat agent's privateensureFileExtensioncan be consolidated onto the shared helper.Type of Change
Testing
createFileResponse, and the URL-fetch naming; affected suites passbun run lint,bun run check:audits(45 audits),docs-manifest:check, andtype-checkpassChecklist