Skip to content

Commit 3622af5

Browse files
committed
fix: Quotes not taken into account for shell commands
1 parent 1ef3d94 commit 3622af5

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group = 'fr.pickaria'
9-
version = '1.7.0'
9+
version = '1.8.0-SNAPSHOT'
1010

1111
repositories {
1212
mavenCentral()
@@ -28,6 +28,7 @@ dependencies {
2828
compileOnly("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT")
2929
annotationProcessor("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT")
3030
implementation("fr.pickaria:messager:1.0-SNAPSHOT")
31+
implementation("org.apache.commons:commons-text:1.14.0")
3132
}
3233

3334
def targetJavaVersion = 17

src/main/java/fr/pickaria/pterodactylpoweraction/api/ShellCommandAPI.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.Gson;
44
import fr.pickaria.pterodactylpoweraction.Configuration;
55
import fr.pickaria.pterodactylpoweraction.PowerActionAPI;
6+
import org.apache.commons.text.StringTokenizer;
67
import org.slf4j.Logger;
78

89
import java.io.File;
@@ -80,7 +81,11 @@ public CompletableFuture<Boolean> isPlayerWhitelisted(String server, String play
8081

8182
private CompletableFuture<Void> runCommands(Optional<String> workingDirectory, String command) {
8283
return CompletableFuture.runAsync(() -> {
83-
ProcessBuilder pb = new ProcessBuilder(command.split(" "));
84+
org.apache.commons.text.StringTokenizer tokenizer = new StringTokenizer(command);
85+
tokenizer.setQuoteChar('\'');
86+
String[] args = tokenizer.getTokenArray();
87+
88+
ProcessBuilder pb = new ProcessBuilder(args);
8489
workingDirectory.ifPresent((value) -> pb.directory(new File(value)));
8590
try {
8691
pb.start().onExit().get();

0 commit comments

Comments
 (0)