Skip to content

Commit

Permalink
ImportHandler: importing files with unknown extension work again when…
Browse files Browse the repository at this point in the history
… allowUnknownFileEnds is true

By specification, when settings.allowUnknownFileEnds is true and the user tries
to import a file with an unknown extension (this includes no extension),
Etherpad tries to import it as txt.

This broke in Etherpad 1.8.0, that abruptly terminates the processing with an
UnhandledPromiseRejectionWarning.

This patch restores the intended behaviour, and allows to import as text a file
with an unknown extension (on no extension).

In order to catch the UnhandledPromiseRejectionWarning we had to use
fsp_rename(), which is declared earlier in the code and is promised based
instead of fs.rename(), which is callback based.

Fixes #3710.
  • Loading branch information
tudorconstantin authored and muxator committed Mar 17, 2020
1 parent a0579c9 commit 28102d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/node/handler/ImportHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async function doImport(req, res, padId)
let oldSrcFile = srcFile;

srcFile = path.join(path.dirname(srcFile), path.basename(srcFile, fileEnding) + ".txt");
await fs.rename(oldSrcFile, srcFile);
await fsp_rename(oldSrcFile, srcFile);
} else {
console.warn("Not allowing unknown file type to be imported", fileEnding);
throw "uploadFailed";
Expand Down

0 comments on commit 28102d8

Please sign in to comment.