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
- フォーク
- 213
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
matthewwithanm/python-markdownify のほかの issue
-
Trailing whitespace strip in <pre> is quadratic on a long whitespace run対応中かも @ac1982 が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Image/link attributes containing `]`, `)`, or spaces produce broken Markdown output対応中かも @assinscreedFC が 139 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
matthewwithanm/python-markdownify#261 · コメント 1 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
matthewwithanm/python-markdownify#259 · リアクション 2 件 ·
-
Recursion Error: Process_element / process_tag mutual recursion (infinite loop)対応中かも @chiliec が 56 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
-
Behavior with strip_pre=mdfy.STRIP_ONE seems incorrect with trailing newlines within the pre対応中かも @oiahoon が 102 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 50/100
matthewwithanm/python-markdownify の issue をすべて見る
似ている issue
-
resource-submission validation-passed
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
hesreallyhim/awesome-claude-code#3214 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
room-commons replace accepts an empty old string and silently prepends the new text to the pageオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
doobidoo/mcp-memory-service#1650 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ml-explore/mlx-lm#2002 ·
メンテナーはふだん 2 日以内に返信