CB-2093: NullPointerException when attaching image from Gallery that contains spaces in the path

Guarding against a null string being passed into FileUtils.getMimeType()
This commit is contained in:
Simon MacDonald 2013-01-08 21:10:41 -05:00
parent c130396d4e
commit a1cfe87f1e

View File

@ -1019,6 +1019,7 @@ public class FileUtils extends CordovaPlugin {
* @return a mime type
*/
public static String getMimeType(String filename) {
if (filename != null) {
// Stupid bug in getFileExtensionFromUrl when the file name has a space
// So we need to replace the space with a url encoded %20
String url = filename.replace(" ", "%20");
@ -1029,6 +1030,9 @@ public class FileUtils extends CordovaPlugin {
} else {
return map.getMimeTypeFromExtension(extension);
}
} else {
return "";
}
}
/**