Skip to content

Commit 0cb8bf7

Browse files
committed
regex to prevent use of control, zero width, etc. characters
1 parent ed7b983 commit 0cb8bf7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/pro/cloudnode/smp/bankaccounts/Command.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import java.util.List;
1414
import java.util.Optional;
1515
import java.util.Set;
16+
import java.util.regex.Matcher;
17+
import java.util.regex.Pattern;
1618
import java.util.stream.Collectors;
1719

1820
public abstract class Command implements CommandExecutor, TabCompleter {
@@ -91,10 +93,8 @@ public final boolean onCommand(final @NotNull CommandSender sender, final @NotNu
9193
.filter(codePoint -> codePoint > 0xFFFF)
9294
.mapToObj(codePoint -> new String(Character.toChars(codePoint)))
9395
.collect(Collectors.toSet());
94-
if (input.contains("<"))
95-
chars.add("<");
96-
if (input.contains(">"))
97-
chars.add(">");
96+
final @NotNull Matcher matcher = Pattern.compile("[<>\\x00-\\x08\\x0B-\\x1F\\x7F-\\x9F\\u2400-\\u2421\\u200B-\\u200D\\uFEFF\\uD800-\\uDB7F\\uDFFF]").matcher(input);
97+
while (matcher.find()) chars.add(matcher.group());
9898
return chars;
9999
}
100100
}

0 commit comments

Comments
 (0)