commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1780731 - /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
Date Sat, 28 Jan 2017 18:41:17 GMT
Author: damjan
Date: Sat Jan 28 18:41:17 2017
New Revision: 1780731

URL: http://svn.apache.org/viewvc?rev=1780731&view=rev
Log:
Match XPM color names case insensitively.

Patch by: me

Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java?rev=1780731&r1=1780730&r2=1780731&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
Sat Jan 28 18:41:17 2017
@@ -36,6 +36,7 @@ import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Properties;
@@ -91,7 +92,7 @@ public class XpmImageParser extends Imag
                             final int green = Integer.parseInt(line.substring(4, 7).trim());
                             final int blue = Integer.parseInt(line.substring(8, 11).trim());
                             final String colorName = line.substring(11).trim();
-                            colors.put(colorName, 0xff000000 | (red << 16)
+                            colors.put(colorName.toLowerCase(Locale.ENGLISH), 0xff000000
| (red << 16)
                                     | (green << 8) | blue);
                         } catch (final NumberFormatException nfe) {
                             throw new ImageReadException("Couldn't parse color in rgb.txt",
nfe);
@@ -353,8 +354,9 @@ public class XpmImageParser extends Imag
             return 0x00000000;
         } else {
             loadColorNames();
-            if (colorNames.containsKey(color)) {
-                return colorNames.get(color);
+            final String colorLowercase = color.toLowerCase(Locale.ENGLISH);
+            if (colorNames.containsKey(colorLowercase)) {
+                return colorNames.get(colorLowercase);
             }
             return 0x00000000;
         }



Mime
View raw message