Skip to content

Commit

Permalink
Merge pull request #2221 from codefori/fix/ifsPathWithBlanks
Browse files Browse the repository at this point in the history
Fixed IFS commands/methods crashing with paths with blanks
  • Loading branch information
worksofliam authored Aug 27, 2024
2 parents 360778b + b8cb6fa commit 1f5fcd7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/api/IBMiContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/api/Terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`) {
Expand Down Expand Up @@ -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)}`);
}
}),

Expand Down

0 comments on commit 1f5fcd7

Please sign in to comment.