aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0290-fix-empty-array-elements-in-command-arguments.patch
blob: 83bcf0fec05c4d0d771656c4dd27adff2b02f638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Trigary <trigary0@gmail.com>
Date: Sat, 5 Jun 2021 10:29:39 +0200
Subject: [PATCH] fix empty array elements in command arguments

Adjacent spaces caused empty array elements due to how String#split works.
This change removes those empty array elements without modifying anything else.
Adjacent spaces sent by players are removed in PlayerConnection, so this change doesn't affect players.
But it does affect the console, command blocks, Bukkit.dispatchCommand, etc.

diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
index 27243a1214bc4d7dbb46f0b9b254c8e3f8128419..b5f9cd2bd191f8b071c6c95706ddbef97d3c244e 100644
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
@@ -131,7 +131,7 @@ public class SimpleCommandMap implements CommandMap {
      */
     @Override
     public boolean dispatch(@NotNull CommandSender sender, @NotNull String commandLine) throws CommandException {
-        String[] args = commandLine.split(" ");
+        String[] args = org.apache.commons.lang3.StringUtils.split(commandLine, ' '); // Paper - fix adjacent spaces (from console/plugins) causing empty array elements
 
         if (args.length == 0) {
             return false;