mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-12 04:37:51 +02:00
Potential fix for code scanning alert no. 44: DOM text reinterpreted as HTML
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
parent
63eb9865c7
commit
0135af8d67
@@ -25,15 +25,12 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||
try {
|
||||
let rawContent = markdownScript.textContent;
|
||||
|
||||
// HTML entity decoding function
|
||||
function decodeHtmlEntities(text) {
|
||||
const tempDiv = document.createElement('div');
|
||||
tempDiv.innerHTML = text;
|
||||
return tempDiv.textContent || tempDiv.innerText || '';
|
||||
}
|
||||
// Import a library for decoding HTML entities
|
||||
import { decode } from 'he';
|
||||
|
||||
// Always decode HTML entities using a safe library
|
||||
rawContent = decode(rawContent);
|
||||
|
||||
// Always decode HTML entities since the browser might encode them
|
||||
rawContent = decodeHtmlEntities(rawContent);
|
||||
|
||||
const data = JSON.parse(rawContent);
|
||||
const content = `# ${data.title}\n\nSource: ${window.location.href}\n\n${data.markdown}`;
|
||||
|
||||
+2
-1
@@ -9,7 +9,8 @@
|
||||
"@langchain/core": "^0.3.38",
|
||||
"@langchain/openai": "^0.4.2",
|
||||
"msgpack-lite": "^0.1.26",
|
||||
"nock": "^14.0.1"
|
||||
"nock": "^14.0.1",
|
||||
"he": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/recommended": "^1.0.8",
|
||||
|
||||
Reference in New Issue
Block a user