-
Notifications
You must be signed in to change notification settings - Fork 133
IEP-1762: Eim gui cli launch fixes #1457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
97693dc
d87cfdd
d475228
fd68f26
268a2c0
b2e5f27
8a1fc12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,12 +33,19 @@ public LinuxEimLauncherStrategy(Display display, MessageConsoleStream standardCo | |
|
|
||
| @Override | ||
| public LaunchResult launch(String eimPath) throws IOException | ||
| { | ||
| return launch(eimPath, new String[0]); | ||
| } | ||
|
|
||
| @Override | ||
| public LaunchResult launch(String eimPath, String... args) throws IOException | ||
| { | ||
| if (!Files.exists(Paths.get(eimPath))) | ||
| throw new IOException("EIM path not found: " + eimPath); //$NON-NLS-1$ | ||
|
|
||
| String quotedPath = ProcessUtils.bashSingleQuote(eimPath); | ||
| String bashCmd = "nohup " + quotedPath + " > /dev/null 2>&1 & echo $!"; //$NON-NLS-1$ //$NON-NLS-2$ | ||
| String argsStr = (args != null && args.length > 0) ? " " + String.join(" ", args) : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ | ||
| String bashCmd = "nohup " + quotedPath + argsStr + " > /dev/null 2>&1 & echo $!"; //$NON-NLS-1$ //$NON-NLS-2$ | ||
|
Comment on lines
+47
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quote each CLI arg before composing the bash command. Line 47 and Line 48 concatenate raw Proposed fix- String argsStr = (args != null && args.length > 0) ? " " + String.join(" ", args) : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ String argsStr = (args != null && args.length > 0)
+ ? " " + java.util.Arrays.stream(args).map(ProcessUtils::bashSingleQuote).collect(java.util.stream.Collectors.joining(" ")) //$NON-NLS-1$
+ : StringUtil.EMPTY;
String bashCmd = "nohup " + quotedPath + argsStr + " > /dev/null 2>&1 & echo $!"; //$NON-NLS-1$ //$NON-NLS-2$🤖 Prompt for AI Agents |
||
|
|
||
| List<String> command = List.of("bash", "-lc", bashCmd); //$NON-NLS-1$ //$NON-NLS-2$ | ||
| Process launcher = new ProcessBuilder(command).redirectErrorStream(true).start(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,14 +33,21 @@ public WindowsEimLauncherStrategy(Display display, MessageConsoleStream standard | |
|
|
||
| @Override | ||
| public LaunchResult launch(String eimPath) throws IOException | ||
| { | ||
| return launch(eimPath, new String[0]); | ||
| } | ||
|
|
||
| @Override | ||
| public LaunchResult launch(String eimPath, String... args) throws IOException | ||
| { | ||
| if (!Files.exists(Paths.get(eimPath))) | ||
| throw new IOException("EIM path not found: " + eimPath); //$NON-NLS-1$ | ||
|
|
||
| String escapedPathForPowershell = eimPath.replace("'", "''"); //$NON-NLS-1$ //$NON-NLS-2$ | ||
| String argsStr = (args != null && args.length > 0) ? " -ArgumentList '" + String.join(" ", args) + "'" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ | ||
| String powershellCmd = String.format( | ||
| "Start-Process -FilePath '%s' -PassThru | Select-Object -ExpandProperty Id", //$NON-NLS-1$ | ||
| escapedPathForPowershell); | ||
| "Start-Process -FilePath '%s'%s -PassThru | Select-Object -ExpandProperty Id", //$NON-NLS-1$ | ||
| escapedPathForPowershell, argsStr); | ||
|
Comment on lines
+47
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Escape and structure PowerShell Line 47–Line 50 inject raw joined args into a quoted PowerShell expression. Args containing Proposed fix- String argsStr = (args != null && args.length > 0) ? " -ArgumentList '" + String.join(" ", args) + "'" : ""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ String argsStr = StringUtil.EMPTY;
+ if (args != null && args.length > 0)
+ {
+ String quotedArgs = java.util.Arrays.stream(args)
+ .map(a -> "'" + a.replace("'", "''") + "'") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ .collect(java.util.stream.Collectors.joining(", ")); //$NON-NLS-1$
+ argsStr = " -ArgumentList " + quotedArgs; //$NON-NLS-1$
+ }
String powershellCmd = String.format(
"Start-Process -FilePath '%s'%s -PassThru | Select-Object -ExpandProperty Id", //$NON-NLS-1$
escapedPathForPowershell, argsStr);🤖 Prompt for AI Agents |
||
|
|
||
| List<String> command = List.of("powershell.exe", "-Command", powershellCmd); //$NON-NLS-1$ //$NON-NLS-2$ | ||
| Process launcher = new ProcessBuilder(command).redirectErrorStream(true).start(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.