Verify Container's name is a string

This commit is contained in:
Miguel González Aravena 2017-08-15 03:46:20 -03:00
parent 628be51429
commit 9597144422
1 changed files with 4 additions and 6 deletions

View File

@ -124,6 +124,8 @@ FileSystemProvider.prototype.getContainers = function(cb) {
FileSystemProvider.prototype.createContainer = function(options, cb) {
var self = this;
var name = options.name;
var hasSlash = (typeof name == 'string' ? name.search('%2F') : false);
name = (hasSlash != -1 ? name.replace(/%2F/gi, '/') : name);
var dir = path.join(this.root, name);
validateName(name, cb) && fs.mkdir(dir, options, function(err) {
if (err) {
@ -180,12 +182,8 @@ FileSystemProvider.prototype.getContainer = function(containerName, cb) {
// File related functions
FileSystemProvider.prototype.upload = function(options, cb) {
var container = options.container;
if (!validateName(container)) {
return writeStreamError(
new Error(g.f('{{FileSystemProvider}}: Invalid name: %s', container)),
cb
);
}
var hasSlash = (typeof container == 'string' ? container.search('%2F') : false);
container = (hasSlash != -1 ? container.replace(/%2F/gi, '/') : container);
var file = options.remote;
if (!validateName(file)) {
return writeStreamError(