changeset 13402:3f00e1b74464

8145388: URLConnection.guessContentTypeFromStream returns image/jpg for some JPEG images Summary: Since "image/jpg" is not a valid Content Type, the method should return "image/jpeg" when APPn marker segment has 'EE' as a marker type. Reviewed-by: prr, bpb Contributed-by: ramanand.patil@oracle.com
author igerasim
date Fri, 25 Dec 2015 16:45:15 +0300
parents f371bdfb7875
children 20d991bc9171
files src/java.base/share/classes/java/net/URLConnection.java
diffstat 1 files changed, 2 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/net/URLConnection.java	Fri Dec 25 16:43:37 2015 +0300
+++ b/src/java.base/share/classes/java/net/URLConnection.java	Fri Dec 25 16:45:15 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1550,7 +1550,7 @@
         }
 
         if (c1 == 0xFF && c2 == 0xD8 && c3 == 0xFF) {
-            if (c4 == 0xE0) {
+            if (c4 == 0xE0 || c4 == 0xEE) {
                 return "image/jpeg";
             }
 
@@ -1565,10 +1565,6 @@
                  c11 == 0)) {
                 return "image/jpeg";
             }
-
-            if (c4 == 0xEE) {
-                return "image/jpg";
-            }
         }
 
         if (c1 == 0xD0 && c2 == 0xCF && c3 == 0x11 && c4 == 0xE0 &&