fix(site-builder): final whole-branch review fixes
C1: HtmlBlock's PURIFY_CONFIG omitted 'style' from ALLOWED_ATTR, so the toolbar colour picker added in this branch was silently deleted by DOMPurify -- issue #2 was regressed, not fixed. Adds style/id plus table tags, with tests pinning the markup path in both render and toHtml. I3: PagesPanel's three confirmation states were not mutually exclusive; cancelling delete revealed an unbidden reset prompt on a destructive action. I5: orphan repair logged at console.warn, which the new console buffer cannot see -- the reporter would never capture the most diagnostic signal for the still-unreproduced drop bug. Also aligns useWhpApi's initial-load failure handling with loadState's fallback. I7: corrects comments (and the design spec) that asserted an orphan "renders somewhere on the canvas", which a mid-plan audit disproved. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
3dd6b54a35
commit
69e61ab4b2
12 files changed
+317
-32
No files matched your search
@@ -22,6 +22,41 @@ describe('purifyHtml', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('purifyHtml markup path (C1 review finding)', () => {
|
||||
test('a style attribute survives sanitization (colour picker output must not be silently dropped)', () => {
|
||||
const out = purifyHtml('<p style="color: #ff0000">red text</p>');
|
||||
expect(out).toBe('<p style="color: #ff0000">red text</p>');
|
||||
});
|
||||
|
||||
test('an id attribute survives sanitization (anchor targets)', () => {
|
||||
const out = purifyHtml('<a href="#section" id="section">link</a>');
|
||||
expect(out).toContain('id="section"');
|
||||
});
|
||||
|
||||
test('a pasted table survives sanitization', () => {
|
||||
const input = '<table><thead><tr><th>Head</th></tr></thead><tbody><tr><td>Cell</td></tr></tbody></table>';
|
||||
expect(purifyHtml(input)).toBe(input);
|
||||
});
|
||||
|
||||
test('script tags still do not survive alongside a style attribute', () => {
|
||||
const out = purifyHtml('<p style="color:#ff0000">ok</p><script>alert(1)</script>');
|
||||
expect(out).not.toContain('<script');
|
||||
expect(out).toContain('style="color:#ff0000"');
|
||||
});
|
||||
|
||||
test('on* handlers still do not survive on an element that also carries style', () => {
|
||||
const out = purifyHtml('<p style="color:#ff0000" onclick="bad()">x</p>');
|
||||
expect(out).not.toContain('onclick');
|
||||
expect(out).toContain('style="color:#ff0000"');
|
||||
});
|
||||
|
||||
test('javascript: URLs still do not survive on an element that also carries style', () => {
|
||||
const out = purifyHtml('<a style="color:#ff0000" href="javascript:void(0)">x</a>');
|
||||
expect(out).not.toContain('javascript:');
|
||||
expect(out).toContain('style="color:#ff0000"');
|
||||
});
|
||||
});
|
||||
|
||||
describe('purifyHtml iframe sandboxing (M-6)', () => {
|
||||
test('forces a restrictive sandbox attribute onto every iframe', () => {
|
||||
const out = purifyHtml('<iframe src="https://example.com/"></iframe>');
|
||||
|
||||
Reference in new issue
Block a user