From 157461ef7f921467968b8043ea78a9e2f7e0d09d Mon Sep 17 00:00:00 2001 From: steve green Date: Thu, 19 Sep 2024 00:20:31 +0800 Subject: [PATCH] fix `\x01` display in modern WI editor --- public/scripts/utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/scripts/utils.js b/public/scripts/utils.js index b63721c16..1fee90a3f 100644 --- a/public/scripts/utils.js +++ b/public/scripts/utils.js @@ -1908,13 +1908,13 @@ export function select2ChoiceClickSubscribe(control, action, { buttonStyle = fal * @returns {string} The html representation of the highlighted regex */ export function highlightRegex(regexStr) { - // Function to escape HTML special characters for safety - const escapeHtml = (str) => str.replace(/[&<>"']/g, match => ({ - '&': '&', '<': '<', '>': '>', '"': '"', '\'': ''', + // Function to escape special characters for safety or readability + const escape = (str) => str.replace(/[&<>"'\x01]/g, match => ({ + '&': '&', '<': '<', '>': '>', '"': '"', '\'': ''', '\x01': '\\x01', })[match]); - // Replace special characters with their HTML-escaped forms - regexStr = escapeHtml(regexStr); + // Replace special characters with their escaped forms + regexStr = escape(regexStr); // Patterns that we want to highlight only if they are not escaped function getPatterns() {