copyToUnique: Fail if source contains destination

To prevent unbounded recursion as in 16547f64c2.
This commit is contained in:
Abe Jellinek 2023-07-27 12:23:39 -04:00
parent 16547f64c2
commit e271b4e494

View file

@ -999,6 +999,10 @@ Zotero.File = new function(){
file = this.pathToFile(file);
newFile = this.pathToFile(newFile);
if (file.contains(newFile)) {
throw new Error("Can't copy file into itself");
}
newFile.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0o644);
var newName = newFile.leafName;
newFile.remove(null);