Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[PLXCOMP-86] Fix case-insensitive string comparisons

Patch by Benjamin Bentmann
  • Loading branch information...
commit 2b8a97008f0e2cb9e7e6b54b4c4dd34037821417 1 parent 7e8cb96
@krosenvold krosenvold authored
View
15 src/main/java/org/codehaus/plexus/archiver/jar/Manifest.java
@@ -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;
@@ -231,11 +232,21 @@ public void setName( String name )
*/
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() + "\"" );
View
6 src/main/java/org/codehaus/plexus/archiver/manager/DefaultArchiverManager.java
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.