Skip to content

Commit 9a454f6

Browse files
committed
fix: unicode replacement string android crash (#3540)
## 🎯 Goal This PR fixes an Android crash in message rendering caused by the Unicode object replacement character (`U+FFFC`) reaching the markdown pipeline. The fix sanitizes message text before markdown generation by normalizing `U+FFFC` to whitespace and treating fully empty results as empty content. Should resolve [this issue](https://getstream.zendesk.com/agent/tickets/79676?brand_id=360003144254). ## 🛠 Implementation details <!-- Provide a description of the implementation --> ## 🎨 UI Changes <!-- Add relevant screenshots --> <details> <summary>iOS</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> <details> <summary>Android</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> ## 🧪 Testing <!-- Explain how this change can be tested (or why it can't be tested) --> ## ☑️ Checklist - [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required) - [ ] PR targets the `develop` branch - [ ] Documentation is updated - [ ] New code is tested in main example apps, including all possible scenarios - [ ] SampleApp iOS and Android - [ ] Expo iOS and Android
1 parent f6b08e4 commit 9a454f6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

package/src/components/Message/MessageSimple/utils/generateMarkdownText.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ describe('generateMarkdownText', () => {
44
it.each([
55
['', null],
66
[' test message ', 'test message'],
7+
['\uFFFC', ''],
8+
[' \uFFFC ', ''],
9+
['hello\uFFFCworld', 'hello world'],
710
['https://www.getstream.io', '[https://www.getstream.io](https://www.getstream.io)'],
811
[
912
'https://getstream-production.s3-accelerate.amazonaws.com/N336903591601695/33e78ef89e64642862a75c5cca2541eaf6b1c924/trimmedVideos/alert/2_270_881/outputVideo.mp4?AWSAccessKeyId=AKIAVJAW2AD2SQVQCBXV&Expires=1699998768&Signature=zdEMCGzf4Pq++16YkPprvN5NAds=',

package/src/components/Message/MessageSimple/utils/generateMarkdownText.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ export const generateMarkdownText = (text?: string) => {
99
return null;
1010
}
1111

12+
const normalizedText = text.replace(/\uFFFC/g, ' ');
13+
1214
// Trim the extra spaces from the text.
13-
let resultText = text.trim();
15+
let resultText = normalizedText.trim();
1416

1517
// List of all the links present in the text.
1618
const linkInfos = parseLinksFromText(resultText);
@@ -24,7 +26,7 @@ export const generateMarkdownText = (text?: string) => {
2426
// Eg: Hi @getstream.io -> Hi @[getstream.io](getstream.io).
2527
const normalRegEx = new RegExp(escapeRegExp(linkInfo.raw), 'g');
2628
const markdown = `[${displayLink}](${linkInfo.url})`;
27-
resultText = text.replace(normalRegEx, markdown);
29+
resultText = normalizedText.replace(normalRegEx, markdown);
2830

2931
// After previous step, in some cases, the mentioned user after `@` might have a link/email so we convert it back to normal raw text.
3032
// Eg: Hi, @[test.user@gmail.com](mailto:test.user@gmail.com) to @test.user@gmail.com.

0 commit comments

Comments
 (0)