diff --git a/Modules/Bar/Widgets/CustomButton.qml b/Modules/Bar/Widgets/CustomButton.qml index a2ef18f70..62867475f 100644 --- a/Modules/Bar/Widgets/CustomButton.qml +++ b/Modules/Bar/Widgets/CustomButton.qml @@ -247,17 +247,25 @@ Item { } function toHtml(str) { - const htmlRegex = /<\/?[a-zA-Z][\s\S]*>/; + const htmlTagRegex = /<\/?[a-zA-Z][^>]*>/g; + const placeholders = []; + let i = 0; + const protectedStr = str.replace(htmlTagRegex, tag => { + placeholders.push(tag); + return `___HTML_TAG_${i++}___`; + }); - if (htmlRegex.test(str)) { - return str; - } + let escaped = protectedStr + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'") + .replace(/\r\n|\r|\n/g, "
"); - const escaped = str.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); + escaped = escaped.replace(/___HTML_TAG_(\d+)___/g, (_, index) => placeholders[Number(index)]); - const withBreaks = escaped.replace(/\r\n|\r|\n/g, "
"); - - return withBreaks; + return escaped; } function runTextCommand() {