Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if(!createdFolderName || !/^[a-zA-Z0-9_-]+$/.test(createdFolderName)) {
return res.status(501).send('Extension folder name was invalid: "' + createdFolderName + '". It should only contain letters, numbers, and - or _');
}
var compressType;
var decompress = new Decompress();
switch(contentType) {
case 'application/x-gzip':
compressType = Decompress.targz;
break;
case 'application/zip':
compressType = Decompress.zip;
break;
case 'application/x-tar':
compressType = Decompress.tar;
break;
case 'application/x-bzip2':
compressType = Decompress.tar;
break;
default:
compressType = null;
}
if(!compressType) {
return res.status(501).send('Please send a zip, gz, bz2, or tar file type.');
}
try {
// Query the entry
var stats = fs.lstatSync(createdFolderPath);
// Is it a directory?
if(!createdFolderName || !/^[a-zA-Z0-9_-]+$/.test(createdFolderName)) {
return res.status(501).send('Extension folder name was invalid: "' + createdFolderName + '". It should only contain letters, numbers, and - or _');
}
var compressType;
var decompress = new Decompress();
switch(contentType) {
case 'application/x-gzip':
compressType = Decompress.targz;
break;
case 'application/zip':
compressType = Decompress.zip;
break;
case 'application/x-tar':
compressType = Decompress.tar;
break;
case 'application/x-bzip2':
compressType = Decompress.tar;
break;
default:
compressType = null;
}
if(!compressType) {
return res.status(501).send('Please send a zip, gz, bz2, or tar file type.');
}
try {
// Query the entry
var stats = fs.lstatSync(app.get('appPath') + 'extensions/' + createdFolderName);
// Is it a directory?
createdFolderPath = path.join(req.app.get('themesPath'), createdFolderName);
var compressType;
var decompress = new Decompress();
switch(contentType) {
case 'application/x-gzip':
compressType = Decompress.targz;
break;
case 'application/zip':
compressType = Decompress.zip;
break;
case 'application/x-tar':
compressType = Decompress.tar;
break;
case 'application/x-bzip2':
compressType = Decompress.tar;
break;
default:
compressType = null;
}
if(!compressType) {
return next(new feathersErrors.NotAcceptable('Please send a zip, gz, bz2, or tar file type.'));
}
try {
// Query the entry
var stats = fs.lstatSync(createdFolderPath);
// Is it a directory?
if (stats.isDirectory()) {
console.log('already exists');
return next(new feathersErrors.NotAcceptable('A theme with that name has already been uploaded. Please choose a different folder name for your theme.'));
createdFolderPath = path.join(app.get('appPath'), 'themes', createdFolderName);
var compressType;
var decompress = new Decompress();
switch(contentType) {
case 'application/x-gzip':
compressType = Decompress.targz;
break;
case 'application/zip':
compressType = Decompress.zip;
break;
case 'application/x-tar':
compressType = Decompress.tar;
break;
case 'application/x-bzip2':
compressType = Decompress.tar;
break;
default:
compressType = null;
}
if(!compressType) {
return res.status(501).send('Please send a zip, gz, bz2, or tar file type.');
}
try {
// Query the entry
var stats = fs.lstatSync(createdFolderPath);
// Is it a directory?
if (stats.isDirectory()) {
return res.status(501).send('A theme with that name has already been uploaded. Please choose a different folder name for your theme.');
}
return next(new feathersErrors.NotAcceptable('Extension folder name was invalid: "' + createdFolderName + '". It should only contain letters, numbers, and - or _'));
}
createdFolderPath = path.join(req.app.get('extensionsPath'), createdFolderName);
var compressType;
var decompress = new Decompress();
switch(contentType) {
case 'application/x-gzip':
compressType = Decompress.targz;
break;
case 'application/zip':
compressType = Decompress.zip;
break;
case 'application/x-tar':
compressType = Decompress.tar;
break;
case 'application/x-bzip2':
compressType = Decompress.tar;
break;
default:
compressType = null;
}
if(!compressType) {
return next(new feathersErrors.NotAcceptable('Please send a zip, gz, bz2, or tar file type.'));
}
try {
// Query the entry
var stats = fs.lstatSync(createdFolderPath);
// Is it a directory?