Merge pull request #5760 from BenLubar/upload-with-no-extension

Fix uploading a file with no extension resulting in invalid-extension even if the file extension list is blank (allow all)
v1.18.x
Barış Soner Uşaklı 8 years ago committed by GitHub
commit 43aab9b5f1

@ -217,13 +217,10 @@ uploadsController.uploadFile = function (uid, uploadedFile, callback) {
};
function saveFileToLocal(uploadedFile, callback) {
var extension = path.extname(uploadedFile.name);
if (!extension || extension === '.') {
return callback(new Error('[[error:invalid-extension]]'));
}
var filename = uploadedFile.name || 'upload';
var extension = path.extname(filename) || '';
filename = Date.now() + '-' + validator.escape(filename.replace(path.extname(uploadedFile.name) || '', '')).substr(0, 255) + extension;
filename = Date.now() + '-' + validator.escape(filename.substr(0, filename.length - extension.length)).substr(0, 255) + extension;
async.waterfall([
function (next) {

Loading…
Cancel
Save