重命名:doc - pg
This commit is contained in:
parent
9939e6eca5
commit
060281d459
@ -24,8 +24,8 @@ class AIAgentFlowBuilder {
|
||||
|
||||
setup_global_agent_info() {
|
||||
// 设置全局变量,让执行器能够获取到智能体信息
|
||||
if (this.frm && this.frm.doc && this.frm.doc.name) {
|
||||
window.current_agent_name = this.frm.doc.name;
|
||||
if (this.frm && this.frm.pg && this.frm.pg.name) {
|
||||
window.current_agent_name = this.frm.pg.name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -639,27 +639,27 @@ function fixImageUrls(html: string): string {
|
||||
function cleanupQuotedContent(html: string): string {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const doc = parser.parseFromString(html, 'text/html')
|
||||
const pg = parser.parseFromString(html, 'text/html')
|
||||
|
||||
// Remove unwanted top-level elements
|
||||
const evilTags = ['script', 'style', 'noscript', 'title', 'meta', 'base', 'head', 'link']
|
||||
for (const tag of evilTags) {
|
||||
for (const el of Array.from(doc.body.getElementsByTagName(tag))) {
|
||||
for (const el of Array.from(pg.body.getElementsByTagName(tag))) {
|
||||
el.remove()
|
||||
}
|
||||
}
|
||||
// Remove external stylesheet links
|
||||
for (const el of Array.from(doc.body.querySelectorAll('link[rel="stylesheet"]'))) {
|
||||
for (const el of Array.from(pg.body.querySelectorAll('link[rel="stylesheet"]'))) {
|
||||
el.remove()
|
||||
}
|
||||
|
||||
// Remove all inline style attributes (prevent original bold/font-size leaks)
|
||||
for (const el of Array.from(doc.body.querySelectorAll('[style]'))) {
|
||||
for (const el of Array.from(pg.body.querySelectorAll('[style]'))) {
|
||||
el.removeAttribute('style')
|
||||
}
|
||||
|
||||
// Remove tracking pixels (1x1 transparent images)
|
||||
for (const img of Array.from(doc.body.querySelectorAll('img'))) {
|
||||
for (const img of Array.from(pg.body.querySelectorAll('img'))) {
|
||||
const w = img.getAttribute('width')
|
||||
const h = img.getAttribute('height')
|
||||
if ((w === '1' || w === '0' || !w) && (h === '1' || h === '0' || !h)) {
|
||||
@ -668,7 +668,7 @@ function cleanupQuotedContent(html: string): string {
|
||||
}
|
||||
|
||||
// Get cleaned body HTML
|
||||
let cleaned = doc.body.innerHTML
|
||||
let cleaned = pg.body.innerHTML
|
||||
|
||||
// Remove any stray HTML comment nodes
|
||||
cleaned = cleaned.replace(/<!--[\s\S]*?-->/g, '')
|
||||
|
||||
@ -203,19 +203,19 @@ function sanitizeHtml(html: string): string {
|
||||
textarea.innerHTML = html
|
||||
const decoded = textarea.value
|
||||
const parser = new DOMParser()
|
||||
const doc = parser.parseFromString(decoded, 'text/html')
|
||||
const pg = parser.parseFromString(decoded, 'text/html')
|
||||
const dangerousSelectors = ['script', 'style', 'iframe', 'object', 'embed', 'applet', 'link[rel="stylesheet"]', 'meta', 'base']
|
||||
dangerousSelectors.forEach(sel => {
|
||||
doc.querySelectorAll(sel).forEach(el => el.remove())
|
||||
pg.querySelectorAll(sel).forEach(el => el.remove())
|
||||
})
|
||||
doc.querySelectorAll('*').forEach(el => {
|
||||
pg.querySelectorAll('*').forEach(el => {
|
||||
const attrs = Array.from(el.attributes)
|
||||
attrs.forEach(attr => {
|
||||
if (/^on/i.test(attr.name)) el.removeAttribute(attr.name)
|
||||
if (/^\s*(javascript|vbscript|data\s*:\s*text\/html)/i.test(attr.value)) el.removeAttribute(attr.name)
|
||||
})
|
||||
})
|
||||
return doc.body.innerHTML
|
||||
return pg.body.innerHTML
|
||||
}
|
||||
|
||||
// ===== Helpers =====
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user