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

This commit is contained in:
Benjamin Rau 2020-05-26 23:59:18 +02:00 committed by GitHub
parent 2639d523e9
commit 4f0f0afe70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

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