Skip to content

Commit

Permalink
Quote the Installer Path (#1941)
Browse files Browse the repository at this point in the history
* Encase the installer path in quotes to protect against spaces in username being parsed poorly, and other path issues. Don't know why we didnt do this before.

* fix linter
  • Loading branch information
nagilson authored Sep 4, 2024
1 parent 5026182 commit 63cbaf1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Please correct your PATH variable or make sure the 'open' utility is installed s
}
else if(workingCommand.commandRoot === 'command')
{
workingCommand = CommandExecutor.makeCommand(`open`, [`-W`, `${path.resolve(installerPath)}`]);
workingCommand = CommandExecutor.makeCommand(`open`, [`-W`, `"${path.resolve(installerPath)}"`]);
}

this.acquisitionContext.eventStream.post(new NetInstallerBeginExecutionEvent(`The OS X .NET Installer has been launched.`));
Expand All @@ -399,7 +399,7 @@ Please correct your PATH variable or make sure the 'open' utility is installed s
}
else
{
const command = `${path.resolve(installerPath)}`;
const command = `"${path.resolve(installerPath)}"`;
let commandOptions : string[] = [];
if(this.file.isElevated(this.acquisitionContext.eventStream))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,15 @@ suite('Windows & Mac Global Installer Tests', () =>

if(os.platform() === 'darwin')
{
assert.isTrue(mockExecutor.attemptedCommand.startsWith('open'), `It ran the right mac command, open. Command found: ${mockExecutor.attemptedCommand}`)
assert.isTrue(mockExecutor.attemptedCommand.includes('-W'), 'It used the -W flag')
assert.isTrue(mockExecutor.attemptedCommand.startsWith('open'), `It ran the right mac command, open. Command found: ${mockExecutor.attemptedCommand}`);
assert.isTrue(mockExecutor.attemptedCommand.includes('-W'), 'It used the -W flag');
assert.isTrue(mockExecutor.attemptedCommand.includes('"'), 'It put the installer in quotes for username with space in it');
}
else if(os.platform() === 'win32')
{
assert.isTrue(fs.existsSync(mockExecutor.attemptedCommand.split(' ')[0]), 'It ran a command to an executable that exists');
const returnedPath = mockExecutor.attemptedCommand.split(' ')[0].slice(1, -1);
assert.isTrue(fs.existsSync(returnedPath), `It ran a command to an executable that exists: ${returnedPath}`);
assert.isTrue(mockExecutor.attemptedCommand.includes('"'), 'It put the installer in quotes for username with space in it');
if(new FileUtilities().isElevated())
{
assert.include(mockExecutor.attemptedCommand, ' /quiet /install /norestart', 'It ran under the hood if it had privileges already');
Expand Down

0 comments on commit 63cbaf1

Please sign in to comment.