From 2e1de26f34c796468af3be9f40ff7e306d6fec7b Mon Sep 17 00:00:00 2001 From: Yaode_owo Date: Fri, 18 Oct 2024 16:23:37 -0400 Subject: [PATCH] fix %-n$s --- main/chatparser.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/chatparser.js b/main/chatparser.js index 414aa28..a9cdd07 100644 --- a/main/chatparser.js +++ b/main/chatparser.js @@ -235,9 +235,9 @@ function parseMinecraftMessage(component) { return "%s"; }); - translateString = translateString.replace(/%(\d+)\$s/g, (match, index, stringindex, string) => { - const argIndex = parseInt(index) - 1; - + translateString = translateString.replace(/%(-?\d+)\$s/g, (match, index, stringindex, string) => { + const argIndex = index - 1; + if (argIndex < 0 || argIndex >= withArgs.length) { DefaultMsg = true; return match; @@ -320,13 +320,13 @@ function parseMinecraftMessageNoColor(component) { }); translateString = translateString.replace(/%(\d+)\$s/g, (match, index, stringindex, string) => { - const argIndex = parseInt(index) - 1; + const argIndex = index - 1; if (argIndex < 0 || argIndex >= withArgs.length) { DefaultMsg = true; return match; } - + if (stringindex > 0 && string[stringindex - 1] === '%') { return match; }