Browse Source

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

Benjamin Rau 4 years ago
parent
commit
4f0f0afe70
No account linked to committer's email address

+ 6
- 2
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewModule.java View File

335
       // convert file extensions to mime types
335
       // convert file extensions to mime types
336
       if (t.matches("\\.\\w+")) {
336
       if (t.matches("\\.\\w+")) {
337
         String mimeType = getMimeTypeFromExtension(t.replace(".", ""));
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
       } else {
343
       } else {
340
         mimeTypes[i] = t;
344
         mimeTypes[i] = t;
341
       }
345
       }
404
     // when our array returned from getAcceptTypes() has no values set from the webview
408
     // when our array returned from getAcceptTypes() has no values set from the webview
405
     // i.e. <input type="file" />, without any "accept" attr
409
     // i.e. <input type="file" />, without any "accept" attr
406
     // will be an array with one empty string element, afaik
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
   private PermissionAwareActivity getPermissionAwareActivity() {
414
   private PermissionAwareActivity getPermissionAwareActivity() {