You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I carefully checked the code, the following can fix the code.
remove FileInfo.safeName function
add a new function:
function getSafeName(fileName) {
var n = fileName;
// Prevent directory traversal and creating hidden system files:
n = path.basename(n).replace(/^.+/, '');
// Prevent overwriting existing files:
while (_existsSync(options.uploadDir + '/' + n)) {
n = n.replace(nameCountRegexp, nameCountFunc);
}
return n;
}
add a code in upload_server.js after line 429
newFileName = getSafeName(newFileName);
hi,
maybe it's is an issue:
FileInfo.prototype.safeName = function () {
// Prevent directory traversal and creating hidden system files:
this.name = path.basename(this.name).replace(/^.+/, '');
// Prevent overwriting existing files:
while (_existsSync(options.uploadDir + '/' + this.name)) {
this.name = this.name.replace(nameCountRegexp, nameCountFunc);
}
};
The options.uploadDir should be options.getDirectory() ?
For example, img.png is in /dir1, when another img.png uploaded, there will be error throw out. Am I right?
Thank you, I like your this upload package.
The text was updated successfully, but these errors were encountered: