Commit 8767cd9
fix: add depth limits to prevent stack overflow on deeply nested tables
Add MAX_TABLE_DEPTH (64) constant to both the DOCX parser and Typst
renderer. Deeply nested tables beyond this limit are silently truncated
instead of causing a stack overflow.
Parser (docx.rs):
- convert_table(), extract_raw_rows(), extract_cell_content() now accept
a depth parameter; top-level callers pass 0
- extract_cell_content() skips nested tables when depth >= MAX_TABLE_DEPTH
Renderer (typst_gen.rs):
- GenCtx gains a table_depth field (default 0)
- generate_table() increments/decrements depth via a wrapper
- generate_cell_content() skips Block::Table when depth >= MAX_TABLE_DEPTH
Fixes #94
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>1 parent 52ac387 commit 8767cd9
2 files changed
+53
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
1013 | 1017 | | |
1014 | 1018 | | |
1015 | 1019 | | |
| 1020 | + | |
1016 | 1021 | | |
1017 | 1022 | | |
1018 | 1023 | | |
| |||
1268 | 1273 | | |
1269 | 1274 | | |
1270 | 1275 | | |
1271 | | - | |
| 1276 | + | |
1272 | 1277 | | |
1273 | 1278 | | |
1274 | 1279 | | |
| |||
1631 | 1636 | | |
1632 | 1637 | | |
1633 | 1638 | | |
| 1639 | + | |
1634 | 1640 | | |
1635 | 1641 | | |
1636 | 1642 | | |
| |||
1648 | 1654 | | |
1649 | 1655 | | |
1650 | 1656 | | |
| 1657 | + | |
1651 | 1658 | | |
1652 | 1659 | | |
1653 | 1660 | | |
1654 | 1661 | | |
1655 | | - | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
1656 | 1665 | | |
1657 | 1666 | | |
1658 | 1667 | | |
| |||
1673 | 1682 | | |
1674 | 1683 | | |
1675 | 1684 | | |
| 1685 | + | |
1676 | 1686 | | |
1677 | 1687 | | |
1678 | 1688 | | |
| |||
1682 | 1692 | | |
1683 | 1693 | | |
1684 | 1694 | | |
| 1695 | + | |
1685 | 1696 | | |
1686 | 1697 | | |
1687 | 1698 | | |
| |||
1706 | 1717 | | |
1707 | 1718 | | |
1708 | 1719 | | |
1709 | | - | |
1710 | | - | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
1711 | 1723 | | |
1712 | 1724 | | |
1713 | 1725 | | |
| |||
1802 | 1814 | | |
1803 | 1815 | | |
1804 | 1816 | | |
| 1817 | + | |
1805 | 1818 | | |
1806 | 1819 | | |
1807 | 1820 | | |
| |||
1811 | 1824 | | |
1812 | 1825 | | |
1813 | 1826 | | |
| 1827 | + | |
1814 | 1828 | | |
1815 | 1829 | | |
1816 | 1830 | | |
| |||
1828 | 1842 | | |
1829 | 1843 | | |
1830 | 1844 | | |
1831 | | - | |
1832 | | - | |
1833 | | - | |
1834 | | - | |
1835 | | - | |
1836 | | - | |
1837 | | - | |
1838 | | - | |
1839 | | - | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
1840 | 1858 | | |
1841 | 1859 | | |
1842 | 1860 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
1270 | 1275 | | |
1271 | 1276 | | |
1272 | 1277 | | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
1273 | 1289 | | |
1274 | 1290 | | |
1275 | 1291 | | |
| |||
1487 | 1503 | | |
1488 | 1504 | | |
1489 | 1505 | | |
1490 | | - | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
1491 | 1512 | | |
1492 | 1513 | | |
1493 | 1514 | | |
| |||
0 commit comments