SPIGOT-4035: Enforce case-sensitivity for chat format code matching.

This maintains case-insensitivity for URL matching, and adds a unit test to verify correct conversion via CraftChatMessage.

By: Hex <hex@hex.lc>
This commit is contained in:
CraftBukkit/Spigot
2018-07-17 16:42:30 -06:00
parent e73592b7b5
commit 844204b345
2 changed files with 28 additions and 1 deletions

View File

@@ -40,7 +40,7 @@ public final class CraftChatMessage {
}
private static class StringMessage {
private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-or])|(\\n)|((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " \\n]|$))))", Pattern.CASE_INSENSITIVE);
private static final Pattern INCREMENTAL_PATTERN = Pattern.compile("(" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + "[0-9a-fk-or])|(\\n)|(?i)((?:(?:https?):\\/\\/)?(?:[-\\w_\\.]{2,}\\.[a-z]{2,4}.*?(?=[\\.\\?!,;:]?(?:[" + String.valueOf(org.bukkit.ChatColor.COLOR_CHAR) + " \\n]|$))))");
private final List<IChatBaseComponent> list = new ArrayList<IChatBaseComponent>();
private IChatBaseComponent currentChatComponent = new ChatComponentText("");