Remove fragment as well as the query from URLs when resolving MIME type

When we try to deduce the MIME type from the file extension of
a URL, strip the fragment off at the same time we are stripping
the query. Otherwise we end up trying to match against some
funny extensions.

Bug:3241908

Change-Id: Ibaa84f0a628f37cd012b6cfbed9a6a666ecae8bb
diff --git a/core/java/android/webkit/MimeTypeMap.java b/core/java/android/webkit/MimeTypeMap.java
index ecce2ce..35483c9 100644
--- a/core/java/android/webkit/MimeTypeMap.java
+++ b/core/java/android/webkit/MimeTypeMap.java
@@ -43,10 +43,16 @@
      */
     public static String getFileExtensionFromUrl(String url) {
         if (!TextUtils.isEmpty(url)) {
+            int fragment = url.lastIndexOf('#');
+            if (fragment > 0) {
+                url = url.substring(0, fragment);
+            }
+
             int query = url.lastIndexOf('?');
             if (query > 0) {
                 url = url.substring(0, query);
             }
+
             int filenamePos = url.lastIndexOf('/');
             String filename =
                 0 <= filenamePos ? url.substring(filenamePos + 1) : url;