svn commit: r179576 - /jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r179576 - /jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java

imario
Author: imario
Date: Thu Jun  2 05:16:31 2005
New Revision: 179576

URL: http://svn.apache.org/viewcvs?rev=179576&view=rev
Log:
PR: 34976
Reported By: Jin Choi <jsc -at- alum.mit.edu>

When replicating files get rid of reserved and maybe dangerous characters. This allows replication of files like "http://hostname.org/fileservlet?file=abc.txt".

Modified:
    jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java

Modified: jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java?rev=179576&r1=179575&r2=179576&view=diff
==============================================================================
--- jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java (original)
+++ jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java Thu Jun  2 05:16:31 2005
@@ -48,6 +48,11 @@
     private File tempDir;
     private long filecount;
 
+    private char[] TMP_RESERVED_CHARS = new char[]
+    {
+        '?', '/', '\\', ' ', '&', '"', '\'', '*', '#', ';', ':', '<', '>', '|'
+    };
+
     /**
      * constructor to set the location of the temporary directory
      *
@@ -133,7 +138,11 @@
     {
         // BUG29007
         // return baseName + "_" + getFilecount() + ".tmp";
-        return "tmp_" + getFilecount() + "_" + baseName;
+
+        // [hidden email]: BUG34976 get rid of maybe reserved and dangerous characters
+        // e.g. to allow replication of http://hostname.org/fileservlet?file=abc.txt
+        String safeBasename = UriParser.encode(baseName, TMP_RESERVED_CHARS).replace('%', '_');
+        return "tmp_" + getFilecount() + "_" + safeBasename;
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]