server: support ~/ path prefix in /{SESSION,STATE}/{OPEN,SAVE}
This commit is contained in:
parent
7f0b66f7df
commit
4c0a574695
2 changed files with 13 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue