maven-wagon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r660422 - in /maven/wagon/trunk: wagon-provider-test/src/main/java/org/apache/maven/wagon/ wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/ wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/w...
Date Tue, 27 May 2008 08:26:16 GMT
Author: brett
Date: Tue May 27 01:26:15 2008
New Revision: 660422

URL: http://svn.apache.org/viewvc?rev=660422&view=rev
Log:
fix some problems with spaces in file names

Modified:
    maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
    maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
    maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlFileListParser.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
    maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSParserTest.java
    maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java

Modified: maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java?rev=660422&r1=660421&r2=660422&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
(original)
+++ maven/wagon/trunk/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
Tue May 27 01:26:15 2008
@@ -508,7 +508,7 @@
         String dirName = "file-list";
 
         String filenames[] =
-            new String[]{"test-resource.txt", "test-resource-b.txt", "test-resource.pom",
"more-resources.dat"};
+            new String[]{"test-resource.txt", "test-resource b.txt", "test-resource.pom",
"more-resources.dat"};
 
         for ( int i = 0; i < filenames.length; i++ )
         {

Modified: maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java?rev=660422&r1=660421&r2=660422&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
Tue May 27 01:26:15 2008
@@ -23,6 +23,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
@@ -326,7 +327,7 @@
         
         resource.setLastModified( source.lastModified() );
         
-        String url = getRepository().getUrl() + "/" + resource.getName();
+        String url = getRepository().getUrl() + "/" + URLEncoder.encode( resource.getName()
);
 
         PutMethod putMethod = new PutMethod( url );
         InputStream is = null;

Modified: maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlFileListParser.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlFileListParser.java?rev=660422&r1=660421&r2=660422&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlFileListParser.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlFileListParser.java
Tue May 27 01:26:15 2008
@@ -29,6 +29,7 @@
 
 import java.io.InputStream;
 import java.io.PrintWriter;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Pattern;
@@ -122,7 +123,7 @@
                                 // Starts with host relative base url "/maven2/"
                                 if ( value.startsWith( basepath ) )
                                 {
-                                    String tst = value.substring( basepath.length() );
+                                    String tst = URLDecoder.decode( value.substring( basepath.length()
) );
                                     if ( validFilename( tst ) )
                                     {
                                         links.add( tst );

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java?rev=660422&r1=660421&r2=660422&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
Tue May 27 01:26:15 2008
@@ -27,6 +27,8 @@
 import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * LSParser 
@@ -36,10 +38,12 @@
  */
 public class LSParser
 {
+    private Pattern PATTERN = Pattern.compile( ".+\\s+[0-9]+\\s+.+\\s+.+\\s+[0-9]+\\s+([0-9]{4}-[0-9]{2}-[0-9]{2}|.+\\s+[0-9]+)\\s+[0-9:]+\\s+(.+?)"
);
+    
     /**
      * Parse a raw "ls -la", and obtain the list of files.
      * 
-     * TODO: Does not handle files with spaces in the name correctly.
+     * @todo use ls -1a and do away with the method all together
      * 
      * @param rawLS the raw LS to parse.
      * @return the list of files found.
@@ -57,12 +61,13 @@
 
             while ( line != null )
             {
-                String[] parts = StringUtils.split( line, " " );
-                if ( parts.length >= 7 )
+                line = line.trim();
+                
+                Matcher m = PATTERN.matcher( line );
+                if ( m.matches() )
                 {
-                    ret.add( parts[parts.length - 1] );
+                    ret.add( m.group( 2 ) );
                 }
-
                 line = br.readLine();
             }
         }

Modified: maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSParserTest.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSParserTest.java?rev=660422&r1=660421&r2=660422&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSParserTest.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSParserTest.java
Tue May 27 01:26:15 2008
@@ -37,14 +37,16 @@
             + "-rw-r--r--  1 joakim joakim 1194 2006-12-11 09:25 pom.xml\n"
             + "-rw-r--r--  1 joakim joakim  662 2006-12-09 18:46 .project\n"
             + "drwxr-xr-x  4 joakim joakim 4096 2006-11-21 12:26 src\n"
+            + "drwxr-xr-x  4 joakim joakim 4096 2006-11-21 12:26 spaced out\n"
             + "drwxr-xr-x  7 joakim joakim 4096 2006-12-11 10:31 .svn\n"
             + "drwxr-xr-x  3 joakim joakim 4096 2006-12-11 08:39 target\n";
 
         LSParser parser = new LSParser();
         List files = parser.parseFiles( rawLS );
         assertNotNull( files );
-        assertEquals( 8, files.size() );
+        assertEquals( 9, files.size() );
         assertTrue( files.contains( "pom.xml" ) );
+        assertTrue( files.contains( "spaced out" ) );
     }
 
     public void testParseOSX() throws TransferFailedException
@@ -55,14 +57,16 @@
             + "-rw-r--r--   1  joakim  joakim  1194 Dec 11 09:25 pom.xml\n"
             + "-rw-r--r--   1  joakim  joakim   662 May  9  2006 .project\n"
             + "drwxr-xr-x   4  joakim  joakim   204 Dec 11 12:26 src\n"
+            + "drwxr-xr-x   4  joakim  joakim   204 Dec 11 12:26 spaced out\n"
             + "drwxr-xr-x   7  joakim  joakim   476 Dec 11 10:31 .svn\n"
             + "drwxr-xr-x   3  joakim  joakim   238 Dec 11 08:39 target\n";
 
         LSParser parser = new LSParser();
         List files = parser.parseFiles( rawLS );
         assertNotNull( files );
-        assertEquals( 8, files.size() );
+        assertEquals( 9, files.size() );
         assertTrue( files.contains( "pom.xml" ) );
+        assertTrue( files.contains( "spaced out" ) );
     }
 
     public void testParseCygwin() throws TransferFailedException
@@ -73,14 +77,16 @@
             + "-rw-r--r--+  1 joakim None 1194 Dec 11 09:25 pom.xml\n"
             + "-rw-r--r--+  1 joakim None  662 May  9  2006 .project\n"
             + "drwxr-xr-x+  4 joakim None    0 Dec 11 12:26 src\n"
+            + "drwxr-xr-x+  4 joakim None    0 Dec 11 12:26 spaced out\n"
             + "drwxr-xr-x+  7 joakim None    0 Dec 11 10:31 .svn\n"
             + "drwxr-xr-x+  3 joakim None    0 Dec 11 08:39 target\n";
         
         LSParser parser = new LSParser();
         List files = parser.parseFiles( rawLS );
         assertNotNull( files );
-        assertEquals( 8, files.size() );
+        assertEquals( 9, files.size() );
         assertTrue( files.contains( "pom.xml" ) );
+        assertTrue( files.contains( "spaced out" ) );
     }
 
     /**
@@ -93,12 +99,14 @@
         String rawLS = "total 6\n"
             + "drwxr-xr-x  3 snicoll  snicoll  512 Feb  7 11:04 .\n"
             + "drwxr-xr-x  3 snicoll  snicoll  512 Feb  7 11:04 ..\n"
-            + "drwxr-xr-x  3 snicoll  snicoll  512 Feb  7 11:04 org\n";
+            + "drwxr-xr-x  3 snicoll  snicoll  512 Feb  7 11:04 org\n"
+            + "drwxr-xr-x  3 snicoll  snicoll  512 Feb  7 11:04 spaced out\n";
 
         LSParser parser = new LSParser();
         List files = parser.parseFiles( rawLS );
         assertNotNull( files );
-        assertEquals( 3, files.size() );
+        assertEquals( 4, files.size() );
         assertTrue( files.contains( "org" ) );
+        assertTrue( files.contains( "spaced out" ) );
     }
 }

Modified: maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
URL: http://svn.apache.org/viewvc/maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java?rev=660422&r1=660421&r2=660422&view=diff
==============================================================================
--- maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
(original)
+++ maven/wagon/trunk/wagon-providers/wagon-webdav/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
Tue May 27 01:26:15 2008
@@ -21,6 +21,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -264,7 +265,7 @@
                     for (int i = 0; i < multiStatus.getResponses().length; i++)
                     {
                         MultiStatusResponse response = multiStatus.getResponses()[i];
-                        String fileName = PathUtils.filename(response.getHref());
+                        String fileName = PathUtils.filename(URLDecoder.decode( response.getHref()));
                         if (!StringUtils.isEmpty(fileName))
                         {
                             dirs.add(fileName);



---------------------------------------------------------------------
To unsubscribe, e-mail: wagon-commits-unsubscribe@maven.apache.org
For additional commands, e-mail: wagon-commits-help@maven.apache.org


Mime
View raw message