security: potential fix for code scanning alert no. 19: DOM text reinterpreted as HTML (#3802)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
Huang Xin
2026-04-09 12:10:49 +08:00
committed by GitHub
parent bfbe92f355
commit 13ff96db85
+2 -2
View File
@@ -58,7 +58,7 @@ export const manageSyntaxHighlighting = (doc: Document, viewSettings: ViewSettin
if (styleElement) styleElement.remove();
doc.querySelectorAll('pre').forEach((block) => {
if ((block as HTMLElement).dataset['highlighted']) {
block.innerHTML = block.textContent || '';
block.textContent = block.textContent || '';
}
});
return;
@@ -78,7 +78,7 @@ export const manageSyntaxHighlighting = (doc: Document, viewSettings: ViewSettin
codeBlocks.forEach((block) => {
// remove any previously applied classes by hljs
block.innerHTML = block.textContent || '';
block.textContent = block.textContent || '';
block.className = block.className.replace(/language-\S+/g, '');
block.classList.remove('hljs');
block.removeAttribute('data-highlighted');