Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix: Ignores disableThirdPartyRequests when using data url.

damencho29663bcec268
diff --git a/react/features/base/participants/middleware.ts b/react/features/base/participants/middleware.ts
index 6910ed15e8..9d75aaf850 100644
--- a/react/features/base/participants/middleware.ts
+++ b/react/features/base/participants/middleware.ts
@@ -30,6 +30,7 @@ import { MEDIA_TYPE } from '../media/constants';
import MiddlewareRegistry from '../redux/MiddlewareRegistry';
import StateListenerRegistry from '../redux/StateListenerRegistry';
import { playSound, registerSound, unregisterSound } from '../sounds/actions';
+import { isImageDataURL } from '../util/uri';
import {
DOMINANT_SPEAKER_CHANGED,
@@ -689,15 +690,20 @@ function _participantJoinedOrUpdated(store: IStore, next: Function, action: AnyA
// even if disableThirdPartyRequests is set to true in config
if (getState()['features/base/config']?.hosts) {
const { disableThirdPartyRequests } = getState()['features/base/config'];
-
- if (!disableThirdPartyRequests && (avatarURL || email || id || name)) {
- const participantId = !id && local ? getLocalParticipant(getState())?.id : id;
- const updatedParticipant = getParticipantById(getState(), participantId);
-
- getFirstLoadableAvatarUrl(updatedParticipant ?? { id: '' }, store)
- .then((urlData?: { isUsingCORS: boolean; src: string; }) => {
- dispatch(setLoadableAvatarUrl(participantId, urlData?.src ?? '', Boolean(urlData?.isUsingCORS)));
- });
+ const participantId = !id && local ? getLocalParticipant(getState())?.id : id;
+
+ if (avatarURL || email || id || name) {
+ if (!disableThirdPartyRequests) {
+ const updatedParticipant = getParticipantById(getState(), participantId);
+
+ getFirstLoadableAvatarUrl(updatedParticipant ?? { id: '' }, store)
+ .then((urlData?: { isUsingCORS: boolean; src: string; }) => {
+ dispatch(setLoadableAvatarUrl(
+ participantId, urlData?.src ?? '', Boolean(urlData?.isUsingCORS)));
+ });
+ } else if (isImageDataURL(avatarURL)) {
+ dispatch(setLoadableAvatarUrl(participantId, avatarURL, false));
+ }
}
}
diff --git a/react/features/base/util/uri.ts b/react/features/base/util/uri.ts
index 34f86b12a8..3a51b67e02 100644
--- a/react/features/base/util/uri.ts
+++ b/react/features/base/util/uri.ts
@@ -39,6 +39,14 @@ const _URI_AUTHORITY_PATTERN = '(//[^/?#]+)';
*/
const _URI_PATH_PATTERN = '([^?#]*)';
+/**
+ * The {@link RegExp} pattern of the image data scheme.
+ *
+ * @private
+ * @type {RegExp}
+ */
+const IMG_DATA_URL: RegExp = /^data:image\/[a-z0-9\-.+]+;base64,/i;
+
/**
* The {@link RegExp} pattern of the protocol of a URI.
*
@@ -690,3 +698,13 @@ export function sanitizeUrl(url?: string | URL): URL | null {
return new URL(result);
}
+
+/**
+ * Check whether the given url is a valid image data url.
+ *
+ * @param {string} url - The url to check.
+ * @returns {boolean} True if the url is a valid image data url, false otherwise.
+ */
+export function isImageDataURL(url: string): boolean {
+ return IMG_DATA_URL.test(url);
+}