-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't allow copying file into its own path #90069
Don't allow copying file into its own path #90069
Conversation
I'd suggest a more broad improvement here:
|
Like which one? The only difference in the OS-specific methods is that they always operate on absolute paths. And
?? |
I mean that this method is naïve and inefficient, and that unless we can't use a native method we might be better off using a native one, only if we're copying from inside a pck or exported project, or from memory, or network, it'd be useful to use native methods But it does use absolute paths though, underlyingly, just in |
The performance is not a concern here and I don't know any native method to handle that. |
There should be generally, absolute paths aren't an issue as such here, or we couldn't do any file management, but anyway, I don't see this very specific check as a very useful safeguard generally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this prevents truncating files, I'd say it's a good improvement already, even if the UX or getting an error message like this isn't great.
Thanks! |
When you copy file into its source path, it will truncate it and then fail to write, resulting in empty file. This PR adds a check to prevent that.