Sanitize dataset ZIP entry names - #4
Draft
vavo wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
..\\..\\outside.jpg, absolute paths, drive-letter paths, or entries with slashes) to survive and create unsafe ZIP entry names on export.Description
isSafeDatasetFileName(filename)to validate that a name is a plain basename without path separators, traversal (..), drive letters, or absolute path prefixes;normalizeDatasetImageName(filename)to normalize.jpegto.jpgand returnnullfor unsafe names; andgetDatasetTextFileName(imageName)to generate paired.txtnames from validated image names.handleZipUpload) to skip ZIP entries that failisSafeDatasetFileNameand to usenormalizeDatasetImageNamewhen constructing browserFileobjects so imported files have safe, normalized names.handleExport) to derive export entry names vianormalizeDatasetImageNameandgetDatasetTextFileName, skipping any items that do not produce safe names instead of writingitem.file.namedirectly into the output ZIP.tests/prompt-settings.test.mjsthat exercise the safety helpers,.jpeg→.jpgnormalization, paired.txtname generation, and several unsafe path variants to prevent regressions.Testing
node --test tests/prompt-settings.test.mjs, which executed the new regression and the existing tests; all tests passed (29passing,0failing).tagpilot.htmlandtests/prompt-settings.test.mjs, and validated the new import/export behavior through the unit tests described above.Codex Task