|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -554,25 +554,20 @@ else if (size == 124)
|
554 | 554 |
|
555 | 555 | iis.mark();
|
556 | 556 | iis.skipBytes(profileData - size);
|
557 |
| - byte[] profile = new byte[profileSize]; |
558 |
| - iis.readFully(profile, 0, profileSize); |
| 557 | + byte[] profile = ReaderUtil. |
| 558 | + staggeredReadByteStream(iis, profileSize); |
559 | 559 | iis.reset();
|
560 | 560 |
|
561 |
| - try { |
562 |
| - if (metadata.colorSpace == PROFILE_LINKED && |
563 |
| - isLinkedProfileAllowed() && |
564 |
| - !isUncOrDevicePath(profile)) |
565 |
| - { |
566 |
| - String path = new String(profile, "windows-1252"); |
| 561 | + if (metadata.colorSpace == PROFILE_LINKED && |
| 562 | + isLinkedProfileAllowed()) |
| 563 | + { |
| 564 | + String path = new String(profile, "windows-1252"); |
567 | 565 |
|
568 |
| - colorSpace = |
569 |
| - new ICC_ColorSpace(ICC_Profile.getInstance(path)); |
570 |
| - } else { |
571 |
| - colorSpace = |
572 |
| - new ICC_ColorSpace(ICC_Profile.getInstance(profile)); |
573 |
| - } |
574 |
| - } catch (Exception e) { |
575 |
| - colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); |
| 566 | + colorSpace = |
| 567 | + new ICC_ColorSpace(ICC_Profile.getInstance(path)); |
| 568 | + } else if (metadata.colorSpace == PROFILE_EMBEDDED) { |
| 569 | + colorSpace = |
| 570 | + new ICC_ColorSpace(ICC_Profile.getInstance(profile)); |
576 | 571 | }
|
577 | 572 | }
|
578 | 573 |
|
@@ -1825,68 +1820,18 @@ public void sequenceStarted(ImageReader src, int minIndex) {}
|
1825 | 1820 | public void readAborted(ImageReader src) {}
|
1826 | 1821 | }
|
1827 | 1822 |
|
1828 |
| - private static Boolean isLinkedProfileDisabled = null; |
| 1823 | + private static Boolean isLinkedProfileAllowed = null; |
1829 | 1824 |
|
1830 | 1825 | private static boolean isLinkedProfileAllowed() {
|
1831 |
| - if (isLinkedProfileDisabled == null) { |
| 1826 | + if (isLinkedProfileAllowed == null) { |
1832 | 1827 | PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() {
|
1833 | 1828 | public Boolean run() {
|
1834 |
| - return Boolean.getBoolean("sun.imageio.plugins.bmp.disableLinkedProfiles"); |
| 1829 | + return Boolean. |
| 1830 | + getBoolean("sun.imageio.bmp.enableLinkedProfiles"); |
1835 | 1831 | }
|
1836 | 1832 | };
|
1837 |
| - isLinkedProfileDisabled = AccessController.doPrivileged(a); |
1838 |
| - } |
1839 |
| - return !isLinkedProfileDisabled; |
1840 |
| - } |
1841 |
| - |
1842 |
| - private static Boolean isWindowsPlatform = null; |
1843 |
| - |
1844 |
| - /** |
1845 |
| - * Verifies whether the byte array contans a unc path. |
1846 |
| - * Non-UNC path examples: |
1847 |
| - * c:\path\to\file - simple notation |
1848 |
| - * \\?\c:\path\to\file - long notation |
1849 |
| - * |
1850 |
| - * UNC path examples: |
1851 |
| - * \\server\share - a UNC path in simple notation |
1852 |
| - * \\?\UNC\server\share - a UNC path in long notation |
1853 |
| - * \\.\some\device - a path to device. |
1854 |
| - */ |
1855 |
| - private static boolean isUncOrDevicePath(byte[] p) { |
1856 |
| - if (isWindowsPlatform == null) { |
1857 |
| - PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() { |
1858 |
| - public Boolean run() { |
1859 |
| - String osname = System.getProperty("os.name"); |
1860 |
| - return (osname != null && |
1861 |
| - osname.toLowerCase().startsWith("win")); |
1862 |
| - } |
1863 |
| - }; |
1864 |
| - isWindowsPlatform = AccessController.doPrivileged(a); |
1865 |
| - } |
1866 |
| - |
1867 |
| - if (!isWindowsPlatform) { |
1868 |
| - /* no need for the check on platforms except windows */ |
1869 |
| - return false; |
1870 |
| - } |
1871 |
| - |
1872 |
| - /* normalize prefix of the path */ |
1873 |
| - if (p[0] == '/') p[0] = '\\'; |
1874 |
| - if (p[1] == '/') p[1] = '\\'; |
1875 |
| - if (p[3] == '/') p[3] = '\\'; |
1876 |
| - |
1877 |
| - |
1878 |
| - if ((p[0] == '\\') && (p[1] == '\\')) { |
1879 |
| - if ((p[2] == '?') && (p[3] == '\\')) { |
1880 |
| - // long path: whether unc or local |
1881 |
| - return ((p[4] == 'U' || p[4] == 'u') && |
1882 |
| - (p[5] == 'N' || p[5] == 'n') && |
1883 |
| - (p[6] == 'C' || p[6] == 'c')); |
1884 |
| - } else { |
1885 |
| - // device path or short unc notation |
1886 |
| - return true; |
1887 |
| - } |
1888 |
| - } else { |
1889 |
| - return false; |
| 1833 | + isLinkedProfileAllowed = AccessController.doPrivileged(a); |
1890 | 1834 | }
|
| 1835 | + return isLinkedProfileAllowed; |
1891 | 1836 | }
|
1892 | 1837 | }
|
0 commit comments