Skip to content

Handle cyclic w references - #482

Open
Isopach wants to merge 1 commit into
mwilliamson:masterfrom
Isopach:handle-cyclic-w-references
Open

Handle cyclic w references#482
Isopach wants to merge 1 commit into
mwilliamson:masterfrom
Isopach:handle-cyclic-w-references

Conversation

@Isopach

@Isopach Isopach commented Jun 16, 2026

Copy link
Copy Markdown

findLevel resolves w:numStyleLink by following the referenced numbering style to another w:num. If those references form a cycle, the lookup currently recurses until Node raises RangeError: Maximum call stack size exceeded.

This change tracks num IDs visited during a single lookup and returns null when a num ID is seen twice. A cyclic chain is therefore treated as having no resolvable level.

No behaviour change for valid documents; existing numbering tests pass unchanged.

Adds one regression test covering a two-entry w:numStyleLink cycle.

Track the num IDs visited during a single findLevel lookup and return null when a num ID repeats, so a cyclic w:numStyleLink chain is treated as having no resolvable level instead of recursing without bound. Adds a regression test covering a two-entry cycle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant