mirror of
https://github.com/turboderp-org/exui.git
synced 2026-04-20 14:29:52 +00:00
Escape HTML in user blocks
This commit is contained in:
@@ -20,6 +20,11 @@ function escapeHTML(html) {
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
function escapeBlock(text) {
|
||||
return text
|
||||
.replace(/([\\`*_{}[\]()#+\-.!>])/g, '\\$1');
|
||||
}
|
||||
|
||||
renderer.code = function(code, infostring, escaped) {
|
||||
const uniqueId = `copy-${Math.random().toString(16).slice(2)}`;
|
||||
let escapedCode = escapeHTML(code);
|
||||
@@ -581,7 +586,10 @@ class ChatBlock {
|
||||
|
||||
let html = "";
|
||||
if (name) html += "<div class='name' style='color: " + col + "'>" + name + "</div>"
|
||||
html += marked.parse(text);
|
||||
if (this.block.author == "user")
|
||||
html += marked.parse(escapeBlock(escapeHTML(text)));
|
||||
else
|
||||
html += marked.parse(text);
|
||||
|
||||
this.textBlock.innerHTML = html;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user