惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
U
Unit 42
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
Stack Overflow Blog
Stack Overflow Blog
爱范儿
爱范儿
博客园 - 司徒正美
Vercel News
Vercel News
I
InfoQ
GbyAI
GbyAI
C
Check Point Blog
B
Blog RSS Feed
Martin Fowler
Martin Fowler
B
Blog
MyScale Blog
MyScale Blog
腾讯CDC
博客园 - Franky
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 三生石上(FineUI控件)

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(security): escape entry.id in HTML export to prevent ...
SebTardif · 2026-05-23 · via Recent Commits to openclaw:main

@@ -494,6 +494,104 @@ describe("export html security hardening", () => {

494494

);

495495

});

496496497+

it("escapes entry.id in element id and data-entry-id attributes", async () => {

498+

const xssId = `"><script>alert(1)</script><div data-x="`;

499+

const session: SessionData = {

500+

header: { id: "session-xss-id", timestamp: now() },

501+

entries: [

502+

{

503+

id: xssId,

504+

parentId: null,

505+

timestamp: now(),

506+

type: "message",

507+

message: { role: "user", content: "hello" },

508+

},

509+

{

510+

id: "safe-child",

511+

parentId: xssId,

512+

timestamp: now(),

513+

type: "message",

514+

message: {

515+

role: "assistant",

516+

content: [{ type: "text", text: "world" }],

517+

},

518+

},

519+

],

520+

leafId: "safe-child",

521+

systemPrompt: "",

522+

tools: [],

523+

};

524+525+

const { document } = await renderTemplate(session);

526+

const messages = requireElement(document.getElementById("messages"), "messages root missing");

527+528+

// Core XSS prevention: no <script> tags should be injected into the DOM

529+

expect(messages.querySelectorAll("script").length).toBe(0);

530+531+

// No attribute breakout: onmouseover, data-x must not appear as real attributes

532+

expect(messages.querySelector("[onmouseover]")).toBeNull();

533+534+

// The copy-link button must exist with the payload safely contained

535+

const copyBtn = requireElement(

536+

messages.querySelector(".copy-link-btn"),

537+

"copy-link button missing",

538+

);

539+

// data-entry-id must be present as a proper attribute (not broken out)

540+

expect(copyBtn.hasAttribute("data-entry-id")).toBe(true);

541+

// No stray attributes from the payload

542+

expect(copyBtn.hasAttribute("data-x")).toBe(false);

543+544+

// The user message element must not have attribute breakout either

545+

const userMsg = requireElement(

546+

messages.querySelector(".user-message"),

547+

"user message element missing",

548+

);

549+

expect(userMsg.getAttribute("data-x")).toBeNull();

550+

// The element id must start with entry- (the payload is contained within)

551+

const elementId = userMsg.getAttribute("id") ?? "";

552+

expect(elementId.startsWith("entry-")).toBe(true);

553+

});

554+555+

it("copy-link round-trip: dataset.entryId matches raw entry.id after browser decoding", async () => {

556+

// IDs with characters that need HTML escaping but should round-trip correctly

557+

const specialId = `msg-with"quotes&amp's`;

558+

const session: SessionData = {

559+

header: { id: "session-roundtrip", timestamp: now() },

560+

entries: [

561+

{

562+

id: specialId,

563+

parentId: null,

564+

timestamp: now(),

565+

type: "message",

566+

message: { role: "user", content: "test" },

567+

},

568+

],

569+

leafId: specialId,

570+

systemPrompt: "",

571+

tools: [],

572+

};

573+574+

const { document } = await renderTemplate(session);

575+

const messages = requireElement(document.getElementById("messages"), "messages root missing");

576+577+

// The copy-link button should exist

578+

const copyBtn = requireElement(

579+

messages.querySelector(".copy-link-btn"),

580+

"copy-link button missing",

581+

);

582+583+

// Browser decodes HTML entities in dataset reads, so dataset.entryId

584+

// must return the RAW entry.id (not the HTML-escaped version).

585+

// This is essential for buildShareUrl() to produce the correct URL.

586+

const datasetValue = (copyBtn as HTMLElement).dataset.entryId;

587+

expect(datasetValue).toBe(specialId);

588+589+

// The DOM element id must also round-trip: getElementById should find it

590+

const userMsg = document.getElementById(`entry-${specialId}`);

591+

expect(userMsg).not.toBeNull();

592+

expect(userMsg?.classList.contains("user-message")).toBe(true);

593+

});

594+497595

it("escapes markdown data-image attributes", async () => {

498596

const dataImage = "data:image/png;base64,AAAA";

499597

const session: SessionData = {