Skip to content

Commit bc8c57e

Browse files
authored
Merge pull request Expensify#67696 from dmkt9/fix/66602-emoji-disappeared
Fix PR 67030 - Emojis disappear after the user sends the message
2 parents 55fbd88 + edf4e6f commit bc8c57e

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/CONST/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,6 +3470,10 @@ const CONST = {
34703470
EMOJIS: /[\p{Extended_Pictographic}\uE000-\uF8FF\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}](\u200D[\p{Extended_Pictographic}\uE000-\uF8FF\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}]|[\u{1F3FB}-\u{1F3FF}]|[\u{E0020}-\u{E007F}]|\uFE0F|\u20E3)*|[\u{1F1E6}-\u{1F1FF}]{2}|[#*0-9]\uFE0F?\u20E3/du,
34713471
// eslint-disable-next-line max-len, no-misleading-character-class
34723472
EMOJI_SKIN_TONES: /[\u{1f3fb}-\u{1f3ff}]/gu,
3473+
/** Regex to match emojis that are not wrapped in `<emoji>` tags */
3474+
get UNWRAPPED_EMOJI() {
3475+
return new RegExp(`(?:(?!<emoji[^>]*>))(${this.EMOJIS.source})(?:(?!</emoji[^>]*>))`, 'gu');
3476+
},
34733477

34743478
PRIVATE_USER_AREA: /[\uE000-\uF8FF\u{F0000}-\u{FFFFD}\u{100000}-\u{10FFFD}]/u,
34753479

src/components/RenderHTML.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, {useMemo} from 'react';
22
import {RenderHTMLSource} from 'react-native-render-html';
33
import useWindowDimensions from '@hooks/useWindowDimensions';
4-
import Parser from '@libs/Parser';
4+
import CONST from '@src/CONST';
55

66
type RenderHTMLProps = {
77
/** HTML string to render */
@@ -15,9 +15,8 @@ type RenderHTMLProps = {
1515
function RenderHTML({html: htmlParam}: RenderHTMLProps) {
1616
const {windowWidth} = useWindowDimensions();
1717
const html = useMemo(() => {
18-
// Sanitize emoji characters already wrapped in <emoji> tags to prevent double-tagging.
19-
const sanitizedHtml = htmlParam.replaceAll(/<\/?emoji>/g, '');
20-
return Parser.replace(sanitizedHtml, {shouldEscapeText: false, filterRules: ['emoji']});
18+
// Wrap all unwrapped emojis in `<emoji>` tags.
19+
return htmlParam.replace(CONST.REGEX.UNWRAPPED_EMOJI, '<emoji>$1</emoji>');
2120
}, [htmlParam]);
2221
return (
2322
<RenderHTMLSource

0 commit comments

Comments
 (0)