Sanitising the paths to the couchDB data directories.

This commit is contained in:
mike12345567 2020-10-07 11:42:28 +01:00
parent 2c3566f686
commit a72d8e42ad
2 changed files with 17 additions and 1 deletions

View File

@ -2,6 +2,7 @@ const PouchDB = require("pouchdb")
const replicationStream = require("pouchdb-replication-stream")
const allDbs = require("pouchdb-all-dbs")
const { budibaseAppsDir } = require("../utilities/budibaseDir")
const { sanitise } = require("../utilities/sanitisedPath")
const env = require("../environment")
const COUCH_DB_URL = env.COUCH_DB_URL || `leveldb://${budibaseAppsDir()}/.data/`
@ -26,4 +27,10 @@ const Pouch = PouchDB.defaults(POUCH_DB_DEFAULTS)
allDbs(Pouch)
module.exports = Pouch
function PouchWrapper(instance) {
Pouch.apply(this, [sanitise(instance)])
}
PouchWrapper.prototype = Object.create(Pouch.prototype)
module.exports = PouchWrapper

View File

@ -27,3 +27,12 @@ exports.join = function(...args) {
exports.resolve = function(...args) {
return path.resolve(...sanitiseArgs(args))
}
/**
* Sanitise a single string
* @param string input string to sanitise
* @returns {string} the final sanitised string
*/
exports.sanitise = function(string) {
return sanitiseArgs([string])[0]
}