Opt-outs for the secure defaults; isPathVisibleIn in construction/logic
- setUnknownIpFactor (0 = old free pass), UNKNOWN_IP_FACTOR exported
- createContentHelpers({ settingsDepth }) and markdown/mcp isPathVisible overrides
- <RenderRichText safeLinks={false}>
- resolveRedirect({ draft: true }) for preview
- isPathVisibleIn(mode, path), pathOf, PathVisibility exported; page route uses it
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4585e0fc69
commit
0fd57c1d6a
@@ -28,3 +28,24 @@ describe('rich text links', () => {
|
||||
expect(out.root.children[0].children[0]).toBe(d.root.children[0].children[0])
|
||||
})
|
||||
})
|
||||
|
||||
describe('RenderRichText', () => {
|
||||
const state = {
|
||||
root: {
|
||||
type: 'root', children: [{ type: 'paragraph', children: [{ type: 'link', children: [{ type: 'text', detail: 0, format: 0, mode: 'normal', style: '', text: 'klik', version: 1 }], fields: { linkType: 'custom', url: 'data:text/html,<script>alert(1)</script>' }, version: 3 }], version: 1 }],
|
||||
direction: null, format: '', indent: 0, version: 1,
|
||||
},
|
||||
}
|
||||
|
||||
// React 19 already blocks javascript: hrefs; data: URLs it renders as is.
|
||||
test('renders unsafe links as # by default; safeLinks={false} keeps them', async () => {
|
||||
const { renderToStaticMarkup } = await import('react-dom/server')
|
||||
const { createElement } = await import('react')
|
||||
const { RenderRichText } = await import('../src/modules/richtext/RenderRichText.js')
|
||||
const html = renderToStaticMarkup(createElement(RenderRichText, { data: state as never }))
|
||||
expect(html).toContain('href="#"')
|
||||
expect(html).not.toContain('data:')
|
||||
const raw = renderToStaticMarkup(createElement(RenderRichText, { data: state as never, safeLinks: false }))
|
||||
expect(raw).toContain('href="data:text/html')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user