-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(storage/local): stop deleting prior to forbidden items check #57421
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
base: master
Are you sure you want to change the base?
fix(storage/local): stop deleting prior to forbidden items check #57421
Conversation
…in rename Signed-off-by: Josh <[email protected]>
On case-insensitive filesystems, the copy+unlink fallback shouldn't be attempted since source/destination can "overlap". Also adds some additional logging for error conditions + one at debug level for a more common scenario. Otherwise just some additional tidying for readability. Signed-off-by: Josh <[email protected]>
Signed-off-by: Josh <[email protected]>
| return false; | ||
| } | ||
|
|
||
| $dstParent = dirname($target); |
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.
Maybe also rename this variable $targetParent
| $this->rmdir($target); | ||
| } elseif ($this->is_file($target)) { | ||
| $this->unlink($target); | ||
| if (!$this->remove($target)) { |
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.
Even if it's current behaviour, I am not sure we need to remove the target when it's a file.
It should be overwritten by the rename. Not sure if it's dependant from filesystem…
| } | ||
| if ($copySuccess && !$unlinkSuccess) { |
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 ($copySuccess && !$unlinkSuccess) { | |
| } elseif (!$unlinkSuccess) { |
Or maybe with early returns?
Summary
During rename operations, if something already exists in the destination path, it gets deleted prior to the forbidden items check. If the check doesn't pass, the operation is aborted but deletion has already occurred.
This PR moves the forbidden items check up so it takes place before any destructive activities occur (see
checkTreeForForbiddenItems).The 2nd commit also addresses an edge case where the copy+unlink fallback could still be triggered for case-only renames on case-insensitive filesystems.
Also included throughout:
remove()TODO
Checklist
3. to review, feature component)stable32)