From adbbec3581166f7e9c0ee1312c63101b8851c924 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Thu, 1 Jun 2023 18:18:44 -0400 Subject: [PATCH] Fix keywords in kit commands not working Don't process b64 item through keyword replacer and don't replace spaces on command strings --- .../essentials/textreader/KeywordReplacer.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java index 8edbfd1241f..699933808ff 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java +++ b/Essentials/src/main/java/com/earth2me/essentials/textreader/KeywordReplacer.java @@ -140,6 +140,13 @@ private void replaceKeywords(final CommandSource sender) { for (int i = 0; i < input.getLines().size(); i++) { String line = input.getLines().get(i); + + // Skip processing b64 encoded items, they will not have keywords in them. + if (line.charAt(0) == '@') { + replaced.add(line); + continue; + } + final Matcher matcher = KEYWORD.matcher(line); while (matcher.find()) { @@ -375,7 +382,10 @@ private String replaceLine(String line, final String fullMatch, final String[] m } if (this.replaceSpacesWithUnderscores) { - replacer = replacer.replace("_", "\\_").replaceAll("\\s", "_"); + // Don't replace spaces with underscores in command nor escape underscores. + if (line.charAt(0) != '/') { + replacer = replacer.replace("_", "\\_").replaceAll("\\s", "_"); + } } //If this is just a regular keyword, lets throw it into the cache