Permalink
Browse files

[PLXCOMP-86] Fix case-insensitive string comparisons

Patch by Benjamin Bentmann
  • Loading branch information...
krosenvold committed Feb 18, 2012
1 parent 7e8cb96 commit 2b8a97008f0e2cb9e7e6b54b4c4dd34037821417
@@ -31,6 +31,7 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.Locale;
import java.util.StringTokenizer;
import java.util.Vector;
import java.util.jar.Attributes;
@@ -230,12 +231,22 @@ public void setName( String name )
* @return the attribute's key.
*/
public String getKey()
+ {
+ return getKey (name );
+ }
+
+ /**
+ * Get the key for the specified attribute name - its name in lower case.
+ *
+ * @return the attribute's key.
+ */
+ private static String getKey( String name )
{
if ( name == null )
{
return null;
}
- return name.toLowerCase();
+ return name.toLowerCase( Locale.ENGLISH );
}
/**
@@ -531,7 +542,7 @@ public String addAttributeAndCheck( Attribute attribute )
return attribute.getValue();
}
- if ( attribute.getKey().startsWith( ATTRIBUTE_FROM.toLowerCase() ) )
+ if ( attribute.getKey().startsWith( Attribute.getKey( ATTRIBUTE_FROM ) ) )
{
warnings.addElement( "Manifest attributes should not start " + "with \"" + ATTRIBUTE_FROM + "\" in \""
+ attribute.getName() + ": " + attribute.getValue() + "\"" );
@@ -19,7 +19,7 @@
import java.io.File;
-
+import java.util.Locale;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.archiver.Archiver;
@@ -95,13 +95,13 @@ private static String getFileExtention ( File file )
{
String path = file.getAbsolutePath();
- String archiveExt = FileUtils.getExtension( path ).toLowerCase();
+ String archiveExt = FileUtils.getExtension( path ).toLowerCase( Locale.ENGLISH );
if ( "gz".equals( archiveExt ) || "bz2".equals( archiveExt ) )
{
String [] tokens = StringUtils.split( path, "." );
- if ( tokens.length > 2 && "tar".equals( tokens[tokens.length -2].toLowerCase() ) )
+ if ( tokens.length > 2 && "tar".equals( tokens[tokens.length -2].toLowerCase( Locale.ENGLISH ) ) )
{
archiveExt = "tar." + archiveExt;
}

0 comments on commit 2b8a970

Please sign in to comment.