@devries-cameron20 / t3code-1 / commits / 83ad26c3a3
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(mobile): prevent invalid HTML entities from crashing markdown (#6495)

Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com>

Simone committed Aug 13, 2026 at 21:08 UTC 83ad26c3a3aeb877ee8bf07c05145ad804717e2e
2 files changed +25 -2
apps/mobile/modules/t3-markdown-text/src/nativeMarkdownText.ts
+9 -2
@@ -70,15 +70,22 @@ const EMPTY_CONTEXT: RunContext = {
70
71 const INLINE_HTML_TAG_PATTERN = /<\/?(?:kbd|mark|sub|sup|u)(?:\s[^>]*)?>/gi;
72
73 +function decodeCodePoint(codePoint: number, entity: string): string {
74 + if (!Number.isInteger(codePoint) || codePoint < 0 || codePoint > 0x10ffff) {
75 + return entity;
76 + }
77 + return String.fromCodePoint(codePoint);
78 +}
79 +
80 function decodeHtmlEntitiesOnce(value: string): string {
81 return value.replace(
82 /&(?:#(\d+)|#x([0-9a-f]+)|amp|apos|gt|lt|nbsp|quot);/gi,
83 (entity, decimal: string | undefined, hexadecimal: string | undefined) => {
84 if (decimal) {
78 - return String.fromCodePoint(Number.parseInt(decimal, 10));
85 + return decodeCodePoint(Number.parseInt(decimal, 10), entity);
86 }
87 if (hexadecimal) {
81 - return String.fromCodePoint(Number.parseInt(hexadecimal, 16));
88 + return decodeCodePoint(Number.parseInt(hexadecimal, 16), entity);
89 }
90 switch (entity.toLowerCase()) {
91 case "&amp;":
apps/mobile/src/lib/nativeMarkdownText.test.ts
+16
@@ -126,6 +126,22 @@ describe("nativeMarkdownTextRuns", () => {
126 ]);
127 });
128
129 + it.each([
130 + ["&#128512;", "😀"],
131 + ["&#x1f680;", "🚀"],
132 + ["&#9999999999;", "&#9999999999;"],
133 + ["&#x110000;", "&#x110000;"],
134 + ["&amp;#9999999999;", "&#9999999999;"],
135 + ["&amp;#x110000;", "&#x110000;"],
136 + ])("normalizes numeric entity %s without throwing", (content, expected) => {
137 + const node: MarkdownNode = {
138 + type: "paragraph",
139 + children: [{ type: "text", content }],
140 + };
141 +
142 + expect(nativeMarkdownTextRuns(node)).toEqual([{ text: expected }]);
143 + });
144 +
145 it("reads inline content from nested text nodes", () => {
146 const node: MarkdownNode = {
147 type: "paragraph",