This commit addresses the issue where scripts fail to execute on Windows environments with usernames containing spaces. The problem stemmed from PowerShell and cmd shell's handling of spaces in quoted arguments. The solution involves encoding PowerShell commands before execution, which mitigates the quoting issues previously causing script failures. This approach is now integrated into the execution flow, ensuring that commands are correctly handled irrespective of user names or other variables that may include spaces. Changes: - Implement encoding for PowerShell commands to handle spaces in usernames and other similar scenarios. - Update script documentation URLs to reflect changes in directory structure. Fixes #351
24 lines
948 B
TypeScript
24 lines
948 B
TypeScript
import { describe } from 'vitest';
|
|
import { PowerShellArgumentEscaper } from '@/infrastructure/CodeRunner/Execution/CommandDefinition/Commands/ShellArgument/PowerShellArgumentEscaper';
|
|
import { runEscapeTests } from './ShellArgumentEscaperTestRunner';
|
|
|
|
describe('PowerShellArgumentEscaper', () => {
|
|
runEscapeTests(() => new PowerShellArgumentEscaper(), [
|
|
{
|
|
description: 'encloses the path in single quotes',
|
|
givenPath: 'C:\\Program Files\\app.exe',
|
|
expectedPath: '\'C:\\Program Files\\app.exe\'',
|
|
},
|
|
{
|
|
description: 'escapes single internal single quotes',
|
|
givenPath: 'C:\\Users\\O\'Reilly\\Documents',
|
|
expectedPath: '\'C:\\Users\\O\'\'Reilly\\Documents\'',
|
|
},
|
|
{
|
|
description: 'escapes multiple internal single quotes',
|
|
givenPath: 'C:\\Program Files\\User\'s Files\\Today\'s Files',
|
|
expectedPath: '\'C:\\Program Files\\User\'\'s Files\\Today\'\'s Files\'',
|
|
},
|
|
]);
|
|
});
|