Browse Source

fix(rn,shared-video) validate URLs to avoid crashes on the native side

master
Saúl Ibarra Corretgé 3 years ago
parent
commit
0b54e005d7
1 changed files with 16 additions and 2 deletions
  1. 16
    2
      react/features/shared-video/components/AbstractSharedVideoDialog.js

+ 16
- 2
react/features/shared-video/components/AbstractSharedVideoDialog.js View File

@@ -66,10 +66,24 @@ export default class AbstractSharedVideoDialog<S: *> extends Component < Props,
66 66
             return false;
67 67
         }
68 68
 
69
-        const youtubeId = getYoutubeId(trimmedLink);
70 69
         const { onPostSubmit } = this.props;
70
+        const youtubeId = getYoutubeId(trimmedLink);
71
+
72
+        if (youtubeId) {
73
+            onPostSubmit(youtubeId);
74
+
75
+            return true;
76
+        }
77
+
78
+        // Check if the URL is valid, native may crash otherwise.
79
+        try {
80
+            // eslint-disable-next-line no-new
81
+            new URL(trimmedLink);
82
+        } catch (_) {
83
+            return false;
84
+        }
71 85
 
72
-        onPostSubmit(youtubeId || trimmedLink);
86
+        onPostSubmit(trimmedLink);
73 87
 
74 88
         return true;
75 89
     }

Loading…
Cancel
Save