mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-24 20:38:14 +00:00
* 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
|
||
|---|---|---|
| .. | ||
| (authenticated) | ||
| (bottom_sheet) | ||
| (modals) | ||
| (unauthenticated) | ||
| _layout.tsx | ||
| +native-intent.ts | ||
| index.tsx | ||