mattermost-mobile-upstream/app/routes
Mattermost Build e6a17d5c0b
[69330] codeblock crash on tap (#9849) (#9852)
* test(code): add regression test for code block crash (MM-69330)

Tapping a code block whose text is valid JSON (e.g. "42", "{...}",
"true") crashed the app. CodeRoute read every param through
usePropsFromParams, which runs safeParseJSON, so `code` was parsed from
a string into a number/object/boolean. Highlighter then called
code.split('\n') on a non-string value, throwing
"code.split is not a function".

This test renders CodeRoute -> CodeScreen -> Highlighter with
JSON-parseable code block contents and asserts the viewer renders the
raw code verbatim. It fails against the current code and passes once
`code` is read via useLocalSearchParams.



* fix(code): prevent code block crash when content is valid JSON (MM-69330)

CodeRoute read every param through usePropsFromParams, which runs
safeParseJSON over each value. A code block whose text is valid JSON
(e.g. "42", "{...}", "true") was therefore coerced from a string into a
number/object/boolean. CodeScreen passed that to the Highlighter, whose
getMaximumLineLength called code.split('\n') on a non-string value,
crashing with "code.split is not a function".

Read `code` directly via useLocalSearchParams so it stays a raw string,
and keep usePropsFromParams for the remaining props (textStyle still
needs JSON parsing).

This is the targeted fix from the ticket. The underlying asymmetry in
usePropsFromParams/propsToParams (which can coerce any JSON-shaped
string param) is a broader latent issue tracked separately.



---------


(cherry picked from commit 77a9c5c460)

Co-authored-by: Guillermo Vayá <guillermo.vaya@mattermost.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 08:06:50 +03:00
..
(authenticated) [69330] codeblock crash on tap (#9849) (#9852) 2026-06-18 08:06:50 +03:00
(bottom_sheet) Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
(modals) Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
(unauthenticated) Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00
_layout.tsx Fix Regressions (#9808) (#9810) 2026-06-04 08:11:23 +08:00
+native-intent.ts resumes slide animation after stopping due to modal system dialog showing (#9792) (#9795) 2026-05-29 08:10:02 +03:00
index.tsx Migrate from RNN to Expo router (#9402) 2026-05-13 17:44:55 +08:00