You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by gr...@apache.org on 2004/11/09 03:19:54 UTC

svn commit: rev 56989 - lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/acting

Author: gregor
Date: Mon Nov  8 18:19:53 2004
New Revision: 56989

Modified:
   lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java
Log:
#29135 convert spaces in asset filenames to underscores

Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java	(original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/acting/UploadAction.java	Mon Nov  8 18:19:53 2004
@@ -70,7 +70,7 @@
 
     public static final String CONTENT_PREFIX = "content";
 
-    public static final String FILE_NAME_REGEXP = "[-a-zA-Z0-9_.]+";
+    public static final String FILE_NAME_REGEXP = "[-a-zA-Z0-9_. ]+";
 
     // optional parameters for meta data according to dublin core
     public static final String[] DUBLIN_CORE_PARAMETERS = { "title", "creator", "subject",
@@ -124,19 +124,20 @@
             getLogger().warn("The filename [" + fileName + "] is not valid for an asset.");
             return null;
         }
+        // convert spaces in the file name to underscores
+        fileName = fileName.replace(' ', '_');
         String mimeType = part.getMimeType();
         int fileSize = part.getSize();
 
         results.put(UPLOADASSET_RETURN_MIMETYPE, mimeType);
         results.put(UPLOADASSET_RETURN_FILESIZE, new Integer(fileSize));
 
-        // FIXME: write fileSize into dc meta data
         dublinCoreParams.put("format", mimeType);
         dublinCoreParams.put("extent", Integer.toString(fileSize));
 
         if (uploadType.equals("asset")) {
             ResourcesManager resourcesMgr = new ResourcesManager(document);
-            assetFile = new File(resourcesMgr.getPath(), part.getFileName());
+            assetFile = new File(resourcesMgr.getPath(), fileName);
 
             if (!resourcesMgr.getPath().exists()) {
                 resourcesMgr.getPath().mkdirs();
@@ -150,7 +151,7 @@
         }
         // must be a content upload then
         else {
-            assetFile = new File(document.getFile().getParent(), part.getFileName());
+            assetFile = new File(document.getFile().getParent(), fileName);
             getLogger().debug("assetFile: " + assetFile);
         }
 

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