RecursionError on deeply nested HTML (about 330 levels), separate from the cyclic-tree case in #256
评估
调研方向
从 markdownify/init.py 中 process_element 和 process_tag 附近的第 228-232、234 以及 287-288 行开始,然后运行 issue 中 330 层嵌套的复现程序。将深度失败与 #256/#274 中对循环树的处理进行比较。完成标准是:深度嵌套的非循环 HTML 不再引发 RecursionError,同时现有的循环案例仍得到覆盖。
由索引模型根据 Issue 内容生成。
描述
process_element / process_tag recurse three Python frames per nesting level (markdownify/__init__.py 228-232, 234, 287-288 on develop), so a plain acyclic tree hits the default recursion limit at around 330 levels. Real mail clients produce this: Outlook wraps quoted replies in empty <div>s and a long thread easily passes that depth.
deep div nesting depth=300: OK len=5
deep div nesting depth=330: RecursionError (maximum recursion depth exceeded)
deep div nesting depth=500: RecursionError (maximum recursion depth exceeded)
cyclic soup (p contains its ancestor div): RecursionError (maximum recursion depth exceeded)
Repro on 1.2.3: https://gist.github.com/HardMax71/bbfc6f70bab3ec6417d4f80324f40387. The one-liner is markdownify("<div>" * 330 + "x" + "</div>" * 330).
I applied the hunk from #274 to 1.2.3 to check: the cyclic case passes, the depth case still fails. So #256/#274 cover cycles and this needs its own guard. Cheapest fix: thread a depth counter through process_tag and past a max_depth option fall back to node.get_text(); a full fix walks node.descendants without recursion.
- 主要语言
- Python
- 星标
- 2.3k
- 派生
- 216
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
matthewwithanm/python-markdownify 的其他 Issue
-
Trailing whitespace strip in <pre> is quadratic on a long whitespace run可能已有人在做 @ac1982 于 19 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
-
Image/link attributes containing `]`, `)`, or spaces produce broken Markdown output可能已有人在做 @assinscreedFC 于 147 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 52/100
matthewwithanm/python-markdownify#261 · 1 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 65/100
matthewwithanm/python-markdownify#259 · 1 条评论 · 2 个 reaction ·
-
Recursion Error: Process_element / process_tag mutual recursion (infinite loop)可能已有人在做 @chiliec 于 64 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 50/100
-
Behavior with strip_pre=mdfy.STRIP_ONE seems incorrect with trailing newlines within the pre可能已有人在做 @oiahoon 于 110 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 50/100
查看 matthewwithanm/python-markdownify 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
pytest-dev/pytest-html#1085 ·
-
难度 2/5 1-3 小时 新手友好度 90/100
pollen-robotics/reachy_mini#1527 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 66/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复