The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): unclosed code fences in HTML blocks no longer freeze PR overviews (#26179)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 27, 2026 at 18:41 UTC
5cf49d2ffd4d9f9dd944932e92464c0bb3c8ee46
2 files changed
+14
-2
apps/mobile/src/lib/markdownDocument.ts
+4
-2
@@ -163,8 +163,10 @@ function markdownHtmlTags(content: string): RegExpExecArray[] {
163
}
164
}
165
if (closingIndex === -1) {
166
- if (fenced) codeRanges.push({ start: opening.index, end: content.length });
167
- continue;
166
+ if (!fenced) continue;
167
+ // An unclosed fence runs to the end of the content, so no later opener matters.
168
+ codeRanges.push({ start: opening.index, end: content.length });
169
+ break;
170
}
171
const closing = delimiters[closingIndex]!;
172
codeRanges.push({ start: opening.index, end: closing.index + closing[0].length });
apps/mobile/src/lib/markdownHtml.test.ts
+10
@@ -75,6 +75,16 @@ describe("HTML in native Markdown", () => {
75
expect(result).toContain('`<img src="inline.png">`');
76
});
77
78
+ it("treats an unclosed fence in an HTML block as code through the end", () => {
79
+ // Sized so the quadratic rescan cannot finish within the test timeout.
80
+ const fences = Array.from({ length: 40_000 }, () => "```x y").join("\n");
81
+ const markdown = `<details>\n<img src="before.png">\n${fences}\n<img src="after.png">\n</details>`;
82
+ const result = markdownHtmlContent(markdown);
83
+ expect(result).toContain("");
84
+ expect(result).not.toContain("<details>");
85
+ expect(result).toContain('<img src="after.png">\n</details>');
86
+ });
87
+
88
it("links HTML anchors in a table cell without breaking the row at <br>", () => {
89
const document = parseMarkdownDocument(
90
"| Status | Preview URL |\n| - | - |\n| Done | <a href='https://commit.example.com'>Commit</a><br><a href='https://branch.example.com'>Branch</a> |",