Skip to content

fix(skills): normalize backslash in ZIP entry names for Windows compatibility#1103

Open
buidackim wants to merge 1 commit intonextlevelbuilder:devfrom
buidackim:fix/zip-backslash-extract
Open

fix(skills): normalize backslash in ZIP entry names for Windows compatibility#1103
buidackim wants to merge 1 commit intonextlevelbuilder:devfrom
buidackim:fix/zip-backslash-extract

Conversation

@buidackim
Copy link
Copy Markdown

Problem

ZIP archives created on Windows may use backslash (\) as path separator instead of forward slash (/) in entry names. When these archives are extracted on Linux, the backslash is treated as a literal character in the filename, causing files like scripts\search.py to be created as a single flat file instead of the proper scripts/search.py directory structure.

This breaks skill execution when skills contain subdirectories (e.g. scripts/, references/).

Root Cause

The ZIP specification (PKZIP APPNOTE) requires forward slashes, but many Windows tools (Python zipfile, .NET ZipArchive, older archivers) produce non-conforming archives with backslashes.

The current extraction logic in skills_upload.go uses filepath.Clean() which does not convert backslashes to forward slashes on Linux (since \ is a valid filename character on Linux).

Fix

Added strings.ReplaceAll(entryName, \, /) normalization before filepath.Clean() during skill ZIP extraction. This is a single-line defensive fix that handles the edge case without affecting correctly-formed archives.

Testing

  • Uploaded a Windows-created ZIP containing scripts\search.py entry
  • Before fix: file created as scripts\search.py (flat) → skill execution fails
  • After fix: file correctly extracted as scripts/search.py (subdirectory) → skill works

…tibility

ZIP archives created on Windows may use backslash (\) as path separator
instead of forward slash (/). When extracted on Linux, this causes files
like 'scripts\search.py' to be created as a single flat file instead of
the proper 'scripts/search.py' directory structure.

The ZIP specification (PKZIP APPNOTE) requires forward slashes, but many
Windows tools produce non-conforming archives.

This adds a strings.ReplaceAll backslash normalization step during skill
ZIP extraction to handle this edge case.
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.

1 participant