fix: return the original dropped File so Electron can resolve its path#152
Merged
Conversation
In a secure context (every Electron app, plus https/localhost) fromDataTransferItem resolved a FileSystemHandle and handed back handle.getFile()'s File. That File loses the on-disk path Electron's webUtils.getPathForFile() needs (electron/electron#33647), which broke drag-and-drop path access from v1.x onward. Return the File captured synchronously from getAsFile() instead - it preserves the original File object identity Electron keys on - and only fall back to handle.getFile() when getAsFile() returned null (e.g. a cross-window drop). The durable handle is still attached either way, and directory traversal is unaffected. Closes react-dropzone/react-dropzone#1411.
|
🎉 This PR is included in version 4.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
What kind of change does this PR introduce?
Did you add tests for your changes?
If relevant, did you update the documentation?
Summary
In a secure context (every Electron app, plus https/localhost)
fromDataTransferItemresolved aFileSystemHandleand handed backhandle.getFile()'sFile. ThatFileloses the on-disk path Electron'swebUtils.getPathForFile()needs (electron/electron#33647), which broke drag-and-drop path access from v1.x onward.Return the
Filecaptured synchronously fromgetAsFile()instead - it preserves the originalFileobject identity Electron keys on - and only fall back tohandle.getFile()whengetAsFile()returned null (e.g. a cross-window drop). The durable handle is still attached either way, and directory traversal is unaffected.Does this PR introduce a breaking change?
No.
Other information