Fix uploading a file with no extension resulting in invalid-extension even if the file extension list is blank (allow all)

v1.18.x
Ben Lubar 8 years ago
parent f4fb9ee04b
commit 07982a3fa2
No known key found for this signature in database
GPG Key ID: 018BAB45DB2D2B24

@ -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