You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/06/23 21:32:06 UTC
svn commit: r787800 -
/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java
Author: bentmann
Date: Tue Jun 23 19:32:05 2009
New Revision: 787800
URL: http://svn.apache.org/viewvc?rev=787800&view=rev
Log:
[MNG-4217] trunk create a directory with %20 in name (trunk rev 787409)
Modified:
maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java
Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java?rev=787800&r1=787799&r2=787800&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java (original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/artifact/repository/MavenArtifactRepository.java Tue Jun 23 19:32:05 2009
@@ -225,7 +225,7 @@
* @param url the url
* @return the host name
*/
- public static String protocol( final String url )
+ private static String protocol( final String url )
{
final int pos = url.indexOf( ":" );
@@ -243,13 +243,14 @@
* @return the basedir of the repository
* @todo need to URL decode for spaces?
*/
- public String basedir( String url )
+ private String basedir( String url )
{
String retValue = null;
if ( protocol.equalsIgnoreCase( "file" ) )
{
retValue = url.substring( protocol.length() + 1 );
+ retValue = decode( retValue );
// special case: if omitted // on protocol, keep path as is
if ( retValue.startsWith( "//" ) )
{
@@ -295,7 +296,33 @@
}
return retValue.trim();
}
-
+
+ /**
+ * Decodes the specified (portion of a) URL. <strong>Note:</strong> This decoder assumes that ISO-8859-1 is used to
+ * convert URL-encoded octets to characters.
+ *
+ * @param url The URL to decode, may be <code>null</code>.
+ * @return The decoded URL or <code>null</code> if the input was <code>null</code>.
+ */
+ private static String decode( String url )
+ {
+ String decoded = url;
+ if ( url != null )
+ {
+ int pos = -1;
+ while ( ( pos = decoded.indexOf( '%', pos + 1 ) ) >= 0 )
+ {
+ if ( pos + 2 < decoded.length() )
+ {
+ String hexStr = decoded.substring( pos + 1, pos + 3 );
+ char ch = (char) Integer.parseInt( hexStr, 16 );
+ decoded = decoded.substring( 0, pos ) + ch + decoded.substring( pos + 3 );
+ }
+ }
+ }
+ return decoded;
+ }
+
public int hashCode()
{
final int prime = 31;