Ugo Cei wrote:
> There is possibly a bug in
> org.apache.cocoon.components.request.multipart.MultipartParser.
>
> Say you have Cocoon running on a Unix server. Send a file from a Unix
> client. The filename is sent as /path/to/file.name, the
> MultipartParser executes:
>
> String fileName = new File((String) headers.get("filename")).getName();
>
> and filename gets to be "file.name", which gets saved as
> <upload-dir>/file.name. All is well.
>
> Now use a Windows client. The filename is sent as C:\PATH\TO\FILE.TXT,
> the call to File.getName() on the Unix server does not know how to
> parse the drive designator and the backslashes and stores thae file as
> <upload-dir>/C:\PATH\TO\FILE.TXT
>
> I'd argue that this is a bug, but I have no idea how to fix it.
Try attached patch; tell me how it works.
Thanks,
Vadim
> Ugo
Index: MultipartParser.java
===================================================================
RCS file:
/home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/components/request/multipart/MultipartParser.java,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 MultipartParser.java
--- MultipartParser.java 23 May 2002 12:01:46 -0000 1.1.2.2
+++ MultipartParser.java 20 Sep 2002 12:28:35 -0000
@@ -233,11 +233,14 @@
if (!saveUploadedFilesToDisk) {
out = new ByteArrayOutputStream();
} else {
- String filePath = uploadDirectory.getPath() + File.separator;
-
- String fileName =
- new File((String) headers.get("filename")).getName();
+ String fileName = (String) headers.get("filename");
+ if(File.separatorChar == '\\')
+ fileName = fileName.replace('/','\\');
+ else
+ fileName = fileName.replace('\\','/');
+ String filePath = uploadDirectory.getPath() + File.separator;
+ String fileName = new File(fileName).getName();
file = new File(filePath + fileName);
if (file.exists()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]