From caca8ea46ac1e72e9163a78ed666321b6a03e2eb Mon Sep 17 00:00:00 2001 From: Ruslan Ishkildin Date: Thu, 11 Jun 2020 15:53:26 +0500 Subject: [PATCH 1/3] bug: match accepts regexp --- lib/helpers/lock-directory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/helpers/lock-directory.js b/lib/helpers/lock-directory.js index c8920c5..0981b37 100644 --- a/lib/helpers/lock-directory.js +++ b/lib/helpers/lock-directory.js @@ -2,7 +2,7 @@ module.exports = function () { let paths = [...arguments]; return new Promise((reslove, reject) => { paths.forEach((path, i) => { - if (path.match('../')) { + if (path.includes('../')) { reject('can\'t access directories above base dir'); } }); From 4136ae49cb5429b0ca97435ed83e8e1c63998be0 Mon Sep 17 00:00:00 2001 From: Jhon Magdalena Date: Sat, 19 Sep 2020 11:06:15 +0200 Subject: [PATCH 2/3] Fixed error on /append --- lib/helpers/lock-directory.js | 4 ++-- lib/routes/append.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/helpers/lock-directory.js b/lib/helpers/lock-directory.js index 0981b37..670c9eb 100644 --- a/lib/helpers/lock-directory.js +++ b/lib/helpers/lock-directory.js @@ -1,11 +1,11 @@ module.exports = function () { let paths = [...arguments]; - return new Promise((reslove, reject) => { + return new Promise((resolve, reject) => { paths.forEach((path, i) => { if (path.includes('../')) { reject('can\'t access directories above base dir'); } }); - reslove(); + resolve(); }); }; diff --git a/lib/routes/append.js b/lib/routes/append.js index c6776f6..bfdd958 100644 --- a/lib/routes/append.js +++ b/lib/routes/append.js @@ -13,6 +13,7 @@ var lockDirectory = require('../helpers/lock-directory'); */ module.exports = (req, res) => { const filePath = path.join(res.locals.baseDir, req.body.path); + const dirPath = path.dirname(filePath); lockDirectory(req.body.path) .then(() => fsp.ensureDir(dirPath)) .then(() => fsp.appendFile(filePath, req.body.contents)) From 65dfa0ca04536bede6a78a2d73e4b9b9b39d135a Mon Sep 17 00:00:00 2001 From: Jhon Magdalena Date: Wed, 23 Sep 2020 00:02:06 +0200 Subject: [PATCH 3/3] .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f80df97..8da2c81 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ server/test-dir/* !server/test-dir/sub-dir/main.css !server/test-dir/index.html node_modules +package-lock.json \ No newline at end of file