Procházet zdrojové kódy

fix(android): add missing null check for fileTypes (#1368 by @bengy)

Benjamin Rau před 4 roky
rodič
revize
4f0f0afe70
No account linked to committer's email address

+ 6
- 2
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java Zobrazit soubor

@@ -335,7 +335,11 @@ public class RNCWebViewModule extends ReactContextBaseJavaModule implements Acti
335 335
       // convert file extensions to mime types
336 336
       if (t.matches("\\.\\w+")) {
337 337
         String mimeType = getMimeTypeFromExtension(t.replace(".", ""));
338
-        mimeTypes[i] = mimeType;
338
+        if(mimeType != null) {
339
+          mimeTypes[i] = mimeType;
340
+        } else {
341
+          mimeTypes[i] = t;
342
+        }
339 343
       } else {
340 344
         mimeTypes[i] = t;
341 345
       }
@@ -404,7 +408,7 @@ public class RNCWebViewModule extends ReactContextBaseJavaModule implements Acti
404 408
     // when our array returned from getAcceptTypes() has no values set from the webview
405 409
     // i.e. <input type="file" />, without any "accept" attr
406 410
     // will be an array with one empty string element, afaik
407
-    return arr.length == 0 || (arr.length == 1 && arr[0].length() == 0);
411
+    return arr.length == 0 || (arr.length == 1 && arr[0] != null && arr[0].length() == 0);
408 412
   }
409 413
 
410 414
   private PermissionAwareActivity getPermissionAwareActivity() {