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(rn,shared-video) validate URLs to avoid crashes on the native side

Saúl Ibarra Corretgé0b54e005d7fa
diff --git a/react/features/shared-video/components/AbstractSharedVideoDialog.js b/react/features/shared-video/components/AbstractSharedVideoDialog.js
index 69fd55bb43..4a70f07c61 100644
--- a/react/features/shared-video/components/AbstractSharedVideoDialog.js
+++ b/react/features/shared-video/components/AbstractSharedVideoDialog.js
@@ -66,10 +66,24 @@ export default class AbstractSharedVideoDialog<S: *> extends Component < Props,
return false;
}
- const youtubeId = getYoutubeId(trimmedLink);
const { onPostSubmit } = this.props;
+ const youtubeId = getYoutubeId(trimmedLink);
+
+ if (youtubeId) {
+ onPostSubmit(youtubeId);
+
+ return true;
+ }
+
+ // Check if the URL is valid, native may crash otherwise.
+ try {
+ // eslint-disable-next-line no-new
+ new URL(trimmedLink);
+ } catch (_) {
+ return false;
+ }
- onPostSubmit(youtubeId || trimmedLink);
+ onPostSubmit(trimmedLink);
return true;
}