Sanitize rendering chat references in Web, Desktop and Obsidian clients

Use textContent instead of innerHTML to append references

Resolves #583
This commit is contained in:
Debanjum Singh Solanky
2023-12-22 18:11:49 +05:30
parent 6879daccc6
commit 6a8c1fe423
3 changed files with 9 additions and 10 deletions

View File

@@ -46,7 +46,7 @@
let short_ref = escaped_ref.slice(0, 100);
short_ref = short_ref.length < escaped_ref.length ? short_ref + "..." : short_ref;
let referenceButton = document.createElement('button');
referenceButton.innerHTML = short_ref;
referenceButton.textContent = short_ref;
referenceButton.id = `ref-${index}`;
referenceButton.classList.add("reference-button");
referenceButton.classList.add("collapsed");
@@ -58,11 +58,11 @@
if (this.classList.contains("collapsed")) {
this.classList.remove("collapsed");
this.classList.add("expanded");
this.innerHTML = escaped_ref;
this.textContent = escaped_ref;
} else {
this.classList.add("collapsed");
this.classList.remove("expanded");
this.innerHTML = short_ref;
this.textContent = short_ref;
}
});