Merge pull request #125 from Dahlgren/bugfix/missions-whitelist-pbo

Whitelist .pbo files for mission upload
This commit is contained in:
Björn Dahlgren 2018-12-02 22:42:19 +01:00 committed by GitHub
commit 442e1a9005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,9 @@
var async = require('async')
var express = require('express') var express = require('express')
var multer = require('multer') var multer = require('multer')
var path = require('path')
var upload = multer({ storage: multer.diskStorage({}) }) var upload = multer({ storage: multer.diskStorage({}) })
var async = require('async')
module.exports = function (missionsManager) { module.exports = function (missionsManager) {
var router = express.Router() var router = express.Router()
@ -11,8 +13,12 @@ module.exports = function (missionsManager) {
}) })
router.post('/', upload.array('missions', 64), function (req, res) { router.post('/', upload.array('missions', 64), function (req, res) {
var missions = req.files.filter(function (file) {
return path.extname(file.originalname) === '.pbo'
})
async.parallelLimit( async.parallelLimit(
req.files.map(function (missionFile) { missions.map(function (missionFile) {
return function (next) { return function (next) {
missionsManager.handleUpload(missionFile, next) missionsManager.handleUpload(missionFile, next)
} }