diff --git a/src/api/IBMiContent.ts b/src/api/IBMiContent.ts index 16a23f040..de5d6d8aa 100644 --- a/src/api/IBMiContent.ts +++ b/src/api/IBMiContent.ts @@ -58,7 +58,7 @@ export default class IBMiContent { } private async convertToUTF8(iconv: string, from: string, to: string, ccsid: string) { - const result = await this.ibmi.sendCommand({ command: `${iconv} -f IBM-${ccsid} -t UTF-8 "${from}" > ${to}` }); + const result = await this.ibmi.sendCommand({ command: `${iconv} -f IBM-${ccsid} -t UTF-8 ${Tools.escapePath(from)} > ${Tools.escapePath(to)}` }); if (result.code === 0) { return result.stdout; } @@ -891,7 +891,7 @@ export default class IBMiContent { */ async isDirectory(remotePath: string) { return (await this.ibmi.sendCommand({ - command: `cd ${remotePath}` + command: `cd ${Tools.escapePath(remotePath)}` })).code === 0; } @@ -953,7 +953,7 @@ export default class IBMiContent { } async getAttributes(path: string | (QsysPath & { member?: string }), ...operands: AttrOperands[]) { - const target = (path = typeof path === 'string' ? path : Tools.qualifyPath(path.library, path.name, path.member, path.asp)); + const target = (path = typeof path === 'string' ? Tools.escapePath(path) : Tools.qualifyPath(path.library, path.name, path.member, path.asp)); const result = await this.ibmi.sendCommand({ command: `${this.ibmi.remoteFeatures.attr} -p ${target} ${operands.join(" ")}` }); if (result.code === 0) { return result.stdout @@ -971,7 +971,7 @@ export default class IBMiContent { } async countFiles(directory: string) { - return Number((await this.ibmi.sendCommand({ command: `cd ${directory} && (ls | wc -l)` })).stdout.trim()); + return Number((await this.ibmi.sendCommand({ command: `cd "${directory}" && (ls | wc -l)` })).stdout.trim()); } objectToToolTip(path: string, object: IBMiObject) { diff --git a/src/api/Terminal.ts b/src/api/Terminal.ts index 9c017a82c..b66630e16 100644 --- a/src/api/Terminal.ts +++ b/src/api/Terminal.ts @@ -5,6 +5,7 @@ import { instance } from '../instantiate'; import { GlobalConfiguration } from './Configuration'; import IBMi from './IBMi'; import Instance from './Instance'; +import { Tools } from './Tools'; function getOrDefaultToUndefined(value: string) { if (value && value !== `default`) { @@ -56,7 +57,7 @@ export namespace Terminal { if (content) { const ifsPath = (await content.isDirectory(ifsNode.path)) ? ifsNode.path : path.dirname(ifsNode.path); const terminal = await selectAndOpen(context, instance, TerminalType.PASE); - terminal?.sendText(`cd ${ifsPath}`); + terminal?.sendText(`cd ${Tools.escapePath(ifsPath)}`); } }),