Repository navigation
fix: リンク・画像の解析が二乗の時間にならず、深い引用でスタックがあふれないようにする - #29
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b499b3ac7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| IMAGE, | ||
| (_, alt: string, src: string, title: string | undefined) => | ||
| `<img src="${src}" alt="${alt}">` + (title ? `<span class="img-caption">${title}</span>` : '') | ||
| hold(`<img src="${src}" alt="${alt}">`) + (title ? `<span class="img-caption">${title}</span>` : '') |
There was a problem hiding this comment.
Resolve code placeholders before holding image attributes
For an image with inline code in its alt text, such as , the first pass has already replaced the code span with a held-code token. Holding the whole <img> then nests that token inside another held value. The final replace does not scan strings returned by its callback, so parse() emits an alt value containing literal NUL-delimited indices (A \u00000\u0000) instead of the code content. This corrupts the image's accessible description and leaks internal placeholders into the generated HTML. Resolve nested tokens with attribute-safe escaping rather than leaving them inside held tags.
Useful? React with 👍 / 👎.
# Conflicts: # src/markdown.ts # test/markdown.test.ts
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…o fix/parser-redos-depth # Conflicts: # src/markdown.ts # test/markdown.test.ts
Markdown のパーサの 2 点を直します。
[や](が並ぶと、リンク・画像の正規表現が開始位置ごとに行末まで読んで戻るため、行の長さの二乗の時間がかかっていました(手元で[a](の繰り返し 200KB に 30 秒)。ippon serveではリクエストのたびに描画するので、その間サーバが止まります。ラベルと URL の長さに上限(1000 / 4000 文字)を付け、URL の部分は(?=(...))\Nで後戻りしないようにしました。400KB で 1.4 秒ほどで、長さに比例します。> > > …と引用を深く入れ子にすると、再帰でスタックがあふれて落ちていました(40KB ほど)。入れ子は 16 段までにし、それより深い>は文字のまま出します。挙動の変更:URL が 4000 文字を超えるリンク・画像は、リンク・画像にならず文字のまま出ます(長い
data:URI を直接書いた画像など)。確認:
test/markdown.test.tsにテストを足し、npm testが通ることを確かめました。