TAPAAL / tapaal-gui

TAPAAL is a tool for verification of Timed-Arc Petri Nets developed at Department of Computer Science at Aalborg University.
https://www.tapaal.net
3 stars 11 forks source link

GUI passing paths with whitespace - fix 2056063 #142

Closed mtygesen closed 7 months ago

mtygesen commented 7 months ago

Fixes: https://bugs.launchpad.net/tapaal/+bug/2056063

srba commented 7 months ago

In other parts of the code, we use Platform.isWindows() to detect that we are running on windows. We should perhaps stick to this.

srba commented 7 months ago

@yrke, there was a problem with mac/linux as it didn't run with the quatations, so now the changes are guarded only for windows. Does it look good to you?

srba commented 7 months ago

At ProcessRunner.java, there is this code that disassembles the arguments to the call into a string array: private String[] getCmdArray(){ String[] argSplit = arguments.split("\s+");
String[] cmdArray = new String[1 + argSplit.length]; cmdArray[0] = file; System.arraycopy(argSplit, 0, cmdArray, 1, argSplit.length);

    return cmdArray;
}

and the process is then executed using: process = Runtime.getRuntime().exec(getCmdArray());

So this looks little bit weird that we first create a string with all the arguments and before the call try to split it into the separate arguments again - and here if we have the spaces in arguments/switches things can go wrong.

I think that a better solution would be to make a class that will maintain the arguments as an array of strings with the method .add that will add strings to the array and then just used that array when doing Runtime.getRuntimed().exec(...).