Skip to content

Commit

Permalink
Replace a split method by a StringTokenizer clas to parse run param.
Browse files Browse the repository at this point in the history
In current implementation for split "Run Paramteres" of project
is used split method that split a String by space. I that not handle
qouted parameters with spaces and split it by space that not allow
to pass the text as parameter with spaces.

To handle this situation the split method are replaced by use the
StringTokenizer class, that support single (`) and duble (") quote
that arrond the tekst as a params.
  • Loading branch information
piotrhoppe committed Oct 16, 2024
1 parent 5aa8f1f commit 14ac4c7
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.util.List;
import java.util.Properties;
import java.util.logging.Logger;
import org.apache.commons.text.StringTokenizer;
import org.apache.commons.text.matcher.StringMatcherFactory;
import org.netbeans.api.extexecution.ExecutionService;
import org.netbeans.api.project.Project;
import org.netbeans.modules.python.PythonOutputLine;
Expand Down Expand Up @@ -57,8 +59,7 @@ public static List<String> getRunArgs(Project owner, DataObject context, boolean
if (owner != null) {
Properties prop = PythonUtility.getProperties(owner, false);
if (!prop.getProperty("nbproject.run.params", "").isEmpty()) {
params = prop.getProperty("nbproject.run.params", "")
.split(" ");
params = new StringTokenizer(prop.getProperty("nbproject.run.params", ""), StringMatcherFactory.INSTANCE.spaceMatcher(), StringMatcherFactory.INSTANCE.quoteMatcher()).getTokenArray();
}
}
if (owner != null && PythonUtility.isPoetry((PythonProject) owner) && !isDebug) {
Expand Down

0 comments on commit 14ac4c7

Please sign in to comment.