Fix escaping quote in chat references to prevent it breaking out of html

This commit is contained in:
Debanjum Singh Solanky
2023-04-27 19:10:55 +08:00
parent 26cb878327
commit 865d12b6f2
2 changed files with 5 additions and 3 deletions

View File

@@ -62,7 +62,7 @@ export class KhojChatModal extends Modal {
generateReference(messageEl: any, reference: string, index: number) {
// Generate HTML for Chat Reference
// `<sup><abbr title="${escaped_ref}" tabindex="0">${index}</abbr></sup>`;
let escaped_ref = reference.replace(/"/g, "\\\"")
let escaped_ref = reference.replace(/"/g, "&quot;")
return messageEl.createEl("sup").createEl("abbr", {
attr: {
title: escaped_ref,

View File

@@ -17,8 +17,10 @@
}
function generateReference(reference, index) {
// Escape reference for HTML rendering
let escaped_ref = reference.replaceAll('"', '&quot;');
// Generate HTML for Chat Reference
let escaped_ref = reference.replaceAll("\"", "\\\"")
return `<sup><abbr title="${escaped_ref}" tabindex="0">${index}</abbr></sup>`;
}