commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject svn commit: r179576 - /jakarta/commons/proper/vfs/trunk/src/java/org/apache/commons/vfs/impl/DefaultFileReplicator.java
Date Thu, 02 Jun 2005 12:16:32 GMT
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;
+
+        // imario@apache.org: 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message