Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(gifs): trim the message before extracting the URL.
Hristo Terezov32f9f8ba9261
diff --git a/react/features/base/react/components/web/Message.tsx b/react/features/base/react/components/web/Message.tsxindex 170cabcbf6..ec56a9143e 100644--- a/react/features/base/react/components/web/Message.tsx+++ b/react/features/base/react/components/web/Message.tsx@@ -4,8 +4,7 @@ import { connect } from 'react-redux';import { IReduxState } from '../../../../app/types';import GifMessage from '../../../../chat/components/web/GifMessage';-import { GIF_PREFIX } from '../../../../gifs/constants';-import { isGifEnabled, isGifMessage } from '../../../../gifs/functions.web';+import { extractGifURL, isGifEnabled, isGifMessage } from '../../../../gifs/functions.web';import Linkify from './Linkify';@@ -55,7 +54,7 @@ class Message extends Component<IProps> {// check if the message is a GIFif (gifEnabled && isGifMessage(text)) {- const url = text.substring(GIF_PREFIX.length, text.length - 1);+ const url = extractGifURL(text);content.push(<GifMessagekey = { url }diff --git a/react/features/chat/components/native/GifMessage.tsx b/react/features/chat/components/native/GifMessage.tsxindex 7d77ee3da9..37d5b769cf 100644--- a/react/features/chat/components/native/GifMessage.tsx+++ b/react/features/chat/components/native/GifMessage.tsx@@ -1,7 +1,7 @@import React from 'react';import { Image, ImageStyle, View } from 'react-native';-import { GIF_PREFIX } from '../../../gifs/constants';+import { extractGifURL } from '../../../gifs/function.any';import styles from './styles';@@ -14,7 +14,7 @@ interface IProps {}const GifMessage = ({ message }: IProps) => {- const url = message.substring(GIF_PREFIX.length, message.length - 1);+ const url = extractGifURL(message);return (<Viewid = 'gif-message'diff --git a/react/features/chat/middleware.ts b/react/features/chat/middleware.tsindex 22b55c221d..77f6d83d01 100644--- a/react/features/chat/middleware.ts+++ b/react/features/chat/middleware.ts@@ -24,8 +24,7 @@ import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';import StateListenerRegistry from '../base/redux/StateListenerRegistry';import { playSound, registerSound, unregisterSound } from '../base/sounds/actions';import { addGif } from '../gifs/actions';-import { GIF_PREFIX } from '../gifs/constants';-import { getGifDisplayMode, isGifEnabled, isGifMessage } from '../gifs/function.any';+import { extractGifURL, getGifDisplayMode, isGifEnabled, isGifMessage } from '../gifs/function.any';import { showMessageNotification } from '../notifications/actions';import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';import { resetNbUnreadPollsMessages } from '../polls/actions';@@ -351,7 +350,7 @@ function _onConferenceMessageReceived(store: IStore,* @returns {void}*/function _handleGifMessageReceived(store: IStore, participantId: string, message: string) {- const url = message.substring(GIF_PREFIX.length, message.length - 1);+ const url = extractGifURL(message);store.dispatch(addGif(participantId, url));}diff --git a/react/features/gifs/function.any.ts b/react/features/gifs/function.any.tsindex b530b83c72..b9c554d528 100644--- a/react/features/gifs/function.any.ts+++ b/react/features/gifs/function.any.ts@@ -71,11 +71,29 @@ export function isGifUrlAllowed(url: string) {* @param {string} message - Message to check.* @returns {boolean}*/-export function isGifMessage(message: string) {- const url = message.substring(GIF_PREFIX.length, message.length - 1);+export function isGifMessage(message = '') {+ const trimmedMessage = message.trim();++ if (!trimmedMessage.toLowerCase().startsWith(GIF_PREFIX)) {+ return false;+ }++ const url = extractGifURL(trimmedMessage);++ return isGifUrlAllowed(url);+}++/**+ * Extracts the URL from a gif message.+ *+ * @param {string} message - The message.+ * @returns {string} - The URL.+ */+export function extractGifURL(message = '') {+ const trimmedMessage = message.trim();++ return trimmedMessage.substring(GIF_PREFIX.length, trimmedMessage.length - 1);- return message.trim().toLowerCase()- .startsWith(GIF_PREFIX) && isGifUrlAllowed(url);}/**