mirror of
https://github.com/Comfy-Org/comfy-swift-sdk.git
synced 2026-11-04 23:47:26 +00:00
[PR #21] [MERGED] fix(transport): sanitize server-influenced output extension #23
Labels
No labels
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-swift-sdk#23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-swift-sdk/pull/21
Author: @mattmillerai
Created: 6/21/2026
Status: ✅ Merged
Merged: 6/21/2026
Merged by: @mattmillerai
Base:
main← Head:fix/sanitize-output-extension📝 Commits (1)
a15a4aafix(transport): sanitize server-influenced output extension before path composition📊 Changes
2 files changed (+45 additions, -1 deletions)
View changed files
📝
Sources/ComfySwiftSDK/Internal/Transport.swift(+13 -1)➕
Tests/ComfySwiftSDKTests/OutputExtensionSanitizationTests.swift(+32 -0)📄 Description
Closes #15.
Transportcomposed the downloaded-output cache path asUUID().<suggestedExtension>, withsuggestedExtensionderived from the server response. A/,\, or..in it could shape the write outside the intended filename inside the caches directory.Fix: a static
sanitizedExtension(_:)— lowercased, constrained to[a-z0-9]{1,10}, falling back tobin. Anything with slashes, dots, traversal, empty, or >10 chars collapses tobin, so the result can never escape theUUID().<ext>shape.Unit tests cover
../-style, slash/backslash-bearing, empty, dotted, and overlong extensions, plus pass-through of ordinary ones (png,JPEG→jpeg,mp4,webp).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.