From d200e8ab92ab20c54050a7beb1190fa9a289ab3e Mon Sep 17 00:00:00 2001 From: RezzedUp Date: Sun, 12 Dec 2021 20:52:49 -0600 Subject: [PATCH] Escape placeholder text. Update dependencies. Bump version. Fixes #31 and #32. --- pom.xml | 4 ++-- .../discordsrv/staffchat/util/MappedPlaceholder.java | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 85590dc..1af2839 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.rezzedup discordsrv-staff-chat - 1.4.1 + 1.4.2 DiscordSRV-Staff-Chat 2017 @@ -43,7 +43,7 @@ org.spigotmc spigot-api - 1.17.1-R0.1-SNAPSHOT + 1.18.1-R0.1-SNAPSHOT provided diff --git a/src/main/java/com/rezzedup/discordsrv/staffchat/util/MappedPlaceholder.java b/src/main/java/com/rezzedup/discordsrv/staffchat/util/MappedPlaceholder.java index 43c18d1..9483264 100644 --- a/src/main/java/com/rezzedup/discordsrv/staffchat/util/MappedPlaceholder.java +++ b/src/main/java/com/rezzedup/discordsrv/staffchat/util/MappedPlaceholder.java @@ -51,11 +51,16 @@ public String get(@NullOr String placeholder) return (result == null) ? "" : String.valueOf(result); } + private static String escape(String literal) + { + return literal.replace("\\", "\\\\").replace("$", "\\$"); + } + public String update(String message) { return PATTERN.matcher(message).replaceAll(mr -> { String value = get(mr.group(1)); - return (value.isEmpty()) ? mr.group() : value; + return escape((value.isEmpty()) ? mr.group() : value); }); }