Index: wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
===================================================================
--- wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java (revision 658410)
+++ wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java (working copy)
@@ -306,6 +306,7 @@
if ( protocol.equals( "file" ) )
{
retValue = url.substring( protocol.length() + 1 );
+ retValue = decode( retValue );
// special case: if omitted // on protocol, keep path as is
if ( retValue.startsWith( "//" ) )
{
@@ -390,6 +391,32 @@
return retValue.trim();
}
+ /**
+ * Decodes the specified (portion of a) URL. Note: This decoder assumes that ISO-8859-1 is used to
+ * convert URL-encoded octets to characters.
+ *
+ * @param url The URL to decode, may be null.
+ * @return The decoded URL or null if the input was null.
+ */
+ 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 static String user( String url )
{
String host = authorization( url );
Index: wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java
===================================================================
--- wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java (revision 658410)
+++ wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java (working copy)
@@ -153,6 +153,11 @@
assertEquals( "c:/temp", PathUtils.basedir( "file:c:/temp" ) );
assertEquals( "c:/temp", PathUtils.basedir( "file:c|/temp" ) );
assertEquals( "/temp", PathUtils.basedir( "file:/temp" ) );
+
+ // URL decoding
+ assertEquals( "c:/my docs", PathUtils.basedir( "file:///c:/my docs" ) );
+ assertEquals( "c:/my docs", PathUtils.basedir( "file:///c:/my%20docs" ) );
+ assertEquals( "c:/name #%20?{}[]<>.txt", PathUtils.basedir( "file:///c:/name%20%23%2520%3F%7B%7D%5B%5D%3C%3E.txt" ) );
}
public void testEmptyBasedir()