diff --git a/CHANGELOG.md b/CHANGELOG.md index 760ef1b7..3afb2b2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - bug fixes - ssl: generate unique certificates (with random serial numbers) to avoid reuse errors. Certificates generated with older versions of o-s-c will be updated automatically. + - `~/` path prefix not recognized when using remote control commands like `/SESSION/SAVE` - remote control - add `/STATE/OPEN` and `/STATE/SAVE` commands diff --git a/src/server/callbacks.js b/src/server/callbacks.js index c3ad48ef..8eb0a723 100644 --- a/src/server/callbacks.js +++ b/src/server/callbacks.js @@ -146,6 +146,12 @@ module.exports = { if (Array.isArray(data.path)) data.path = path.resolve(...data.path) + if (data.path && data.path.startsWith('~')) { + // Resolve '~' to user's home directory + var p = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'] + if (p) data.path = data.path.replace( '~', p ) + } + fs.readFile(data.path, 'utf8', (err, result)=>{ var error @@ -186,6 +192,12 @@ module.exports = { if (Array.isArray(data.path)) data.path = path.resolve(...data.path) + if (data.path.startsWith('~')) { + // Resolve '~' to user's home directory + var p = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'] + if (p) data.path = data.path.replace( '~', p ) + } + var root = settings.read('remote-root') if (root && !data.path.includes(root)) { console.error('(ERROR) Could not save: path outside of remote-root')