Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d005a10 authored by Kristian Monsen's avatar Kristian Monsen
Browse files

Find mime from file extension if the mime is empty

Fix for bug 3170039

Change-Id: I6d32ae157ec276575aad8fbcd73f02c48fe219d0
parent 558cf799
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1075,6 +1075,18 @@ class BrowserFrame extends Handler {
     */
    private void downloadStart(String url, String userAgent,
            String contentDisposition, String mimeType, long contentLength) {
        // This will only work if the url ends with the filename
        if (mimeType.isEmpty()) {
            try {
                String extension = url.substring(url.lastIndexOf('.') + 1);
                mimeType = libcore.net.MimeUtils.guessMimeTypeFromExtension(extension);
                // MimeUtils might return null, not sure if downloadmanager is happy with that
                if (mimeType == null)
                    mimeType = "";
            } catch(IndexOutOfBoundsException exception) {
                // mimeType string end with a '.', not much to do
            }
        }
        mimeType = MimeTypeMap.getSingleton().remapGenericMimeType(
                mimeType, url, contentDisposition);
        mCallbackProxy.onDownloadStart(url, userAgent,