From 103d9a91a927f177a4910f48e29e4be6cb6d4e32 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 30 Oct 2017 14:45:41 -0400 Subject: [PATCH] Revert "sanitizing uploaded filename without using slugify, in composer, re comment in: #6011" This reverts commit 9f670fe586a9858826eec12667be161661c065e4. --- package.json | 2 +- src/file.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8c6fcfce63..194c941454 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "morgan": "^1.9.0", "mousetrap": "^1.6.1", "nconf": "^0.8.5", - "nodebb-plugin-composer-default": "6.0.2", + "nodebb-plugin-composer-default": "6.0.1", "nodebb-plugin-dbsearch": "2.0.8", "nodebb-plugin-emoji-extended": "1.1.1", "nodebb-plugin-emoji-one": "1.2.1", diff --git a/src/file.js b/src/file.js index eeb46121f3..ec86c624b1 100644 --- a/src/file.js +++ b/src/file.js @@ -8,9 +8,20 @@ var jimp = require('jimp'); var mkdirp = require('mkdirp'); var mime = require('mime'); +var utils = require('./utils'); + var file = module.exports; file.saveFileToLocal = function (filename, folder, tempPath, callback) { + /* + * remarkable doesn't allow spaces in hyperlinks, once that's fixed, remove this. + */ + filename = filename.split('.'); + filename.forEach(function (name, idx) { + filename[idx] = utils.slugify(name); + }); + filename = filename.join('.'); + var uploadPath = path.join(nconf.get('upload_path'), folder, filename); winston.verbose('Saving file ' + filename + ' to : ' + uploadPath);