From 3a47a9b01024cb4fc7a16f4dbe5ed182a1656bc8 Mon Sep 17 00:00:00 2001 From: Dominik Reh Date: Fri, 14 Oct 2022 09:38:51 +0200 Subject: [PATCH] Insert results as textContent instead of innerHtml Fixes #7 --- tagAutocomplete.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tagAutocomplete.js b/tagAutocomplete.js index 2fd9d0c..2ffa72b 100644 --- a/tagAutocomplete.js +++ b/tagAutocomplete.js @@ -210,7 +210,13 @@ function insertTextAtCursor(textArea, result, tagword) { sanitizedText = acConfig.replaceUnderscores ? text.replaceAll("_", " ") : text; } - sanitizedText = acConfig.escapeParentheses ? sanitizedText.replaceAll("(", "\\(").replaceAll(")", "\\)") : sanitizedText; + if (acConfig.escapeParentheses) { + sanitizedText = sanitizedText + .replaceAll("(", "\\(") + .replaceAll(")", "\\)") + .replaceAll("[", "\\[") + .replaceAll("]", "\\]"); + } var prompt = textArea.value; @@ -269,7 +275,7 @@ function addResultsToList(textArea, results, tagword) { for (let i = 0; i < results.length; i++) { let result = results[i]; let li = document.createElement("li"); - li.innerHTML = result[0]; + li.textContent = result[0]; // Wildcards have no tag type if (!result[1].startsWith("wildcard")) {