Merge pull request #677 from th-h/master

Prevent renaming ML object into existing file.
This commit is contained in:
Thomas Hochstein 2020-03-20 17:55:09 +01:00 committed by GitHub
commit bf59bca988
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -1,6 +1,9 @@
Version 2.4-alpha1 ()
------------------------------------------------------------------------
* Fix: Prevent renaming a ML object into an existing file,
resulting in deletion of both from disk and database.
* Fix invalid HTTP referrer error when trying to delete a
trackback from the frontend

View File

@ -2260,6 +2260,10 @@ function serendipity_renameFile($id, $newName, $path = null) {
$imgBase = $serendipity['serendipityPath'] . $serendipity['uploadPath'];
$newPath = "{$imgBase}{$path}{$newName}.{$file['extension']}";
if (file_exists($newPath)) {
return false;
}
rename("{$imgBase}{$file['path']}{$file['realname']}", $newPath);