From a7233a594f2d080322e4c7ac2541b3dff9c65eb3 Mon Sep 17 00:00:00 2001 From: DominikDoom Date: Sat, 14 Oct 2023 16:19:34 +0200 Subject: [PATCH] Escape $ signs for the insert functions Fixes #248, as discussed in #247 --- javascript/tagAutocomplete.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/javascript/tagAutocomplete.js b/javascript/tagAutocomplete.js index f1755f6..dcee22e 100644 --- a/javascript/tagAutocomplete.js +++ b/javascript/tagAutocomplete.js @@ -489,6 +489,10 @@ async function insertTextAtCursor(textArea, result, tagword, tabCompletedWithout optionalSeparator = TAC_CFG.extraNetworksSeparator || " "; } + // Escape $ signs since they are special chars for the replace function + // We need four since we're also escaping them in replaceAll in the first place + sanitizedText = sanitizedText.replaceAll("$", "$$$$"); + // Replace partial tag word with new text, add comma if needed let insert = surrounding.replace(match, sanitizedText + optionalSeparator);