3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 06:35:44 +01:00

Answer security round 1: 0 🔴, 1 🟡 (0 misread); build the refusal's path in linear time

This commit is contained in:
2026-11-04 20:22:16 +01:00
committed by Lillem4n
parent 977729621c
commit 13f03a4281
2 changed files with 12 additions and 2 deletions
+2 -1
View File
@@ -154,7 +154,8 @@ function refusedShape(content: readonly AdfNode[]): Result<never> | undefined {
for (let step = pending.pop(); step !== undefined; step = pending.pop()) {
if (step.node.type === 'inlineCard' && nodeMarks(step.node).some(({ type }) => type === 'link')) {
const path: (number | string)[] = []
for (let up: Step | undefined = step; up !== undefined; up = up.parent) path.unshift('content', up.index)
for (let up: Step | undefined = step; up !== undefined; up = up.parent) path.push(up.index, 'content')
path.reverse()
return failure('unsupported-node-shape', 'an inlineCard takes no link mark: this one holds one', path)
}
for (const child of nodeContent(step.node).map((node, index) => ({ index, node, parent: step })).reverse()) pending.push(child)