Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
[PLXCOMP-86] Fix case-insensitive string comparisons
Browse files Browse the repository at this point in the history
Patch by Benjamin Bentmann
  • Loading branch information
krosenvold committed Feb 18, 2012
1 parent 7e8cb96 commit 2b8a970
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 13 additions & 2 deletions src/main/java/org/codehaus/plexus/archiver/jar/Manifest.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Locale;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector; import java.util.Vector;
import java.util.jar.Attributes; import java.util.jar.Attributes;
Expand Down Expand Up @@ -230,12 +231,22 @@ public void setName( String name )
* @return the attribute's key. * @return the attribute's key.
*/ */
public String getKey() 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 ) if ( name == null )
{ {
return null; return null;
} }
return name.toLowerCase(); return name.toLowerCase( Locale.ENGLISH );
} }


/** /**
Expand Down Expand Up @@ -531,7 +542,7 @@ public String addAttributeAndCheck( Attribute attribute )
return attribute.getValue(); 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 \"" warnings.addElement( "Manifest attributes should not start " + "with \"" + ATTRIBUTE_FROM + "\" in \""
+ attribute.getName() + ": " + attribute.getValue() + "\"" ); + attribute.getName() + ": " + attribute.getValue() + "\"" );
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@




import java.io.File; import java.io.File;

import java.util.Locale;
import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.archiver.Archiver; import org.codehaus.plexus.archiver.Archiver;
Expand Down Expand Up @@ -95,13 +95,13 @@ private static String getFileExtention ( File file )
{ {
String path = file.getAbsolutePath(); 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 ) ) if ( "gz".equals( archiveExt ) || "bz2".equals( archiveExt ) )
{ {
String [] tokens = StringUtils.split( path, "." ); 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; archiveExt = "tar." + archiveExt;
} }
Expand Down

0 comments on commit 2b8a970

Please sign in to comment.