commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Noel J. Bergman" <n...@devtech.com>
Subject RE: [PATH]FileUpload fix for filename for msiexplorer
Date Sat, 28 Jun 2003 20:05:31 GMT
> FileUpload should not be in the business of deciding, on behalf of its
> client, how to interpret the content of fields uploaded by the browser.

+1

> > Method getName() in DefaultFileItem.java class when used with
> > msiexplorer 5/6 returns a filename with the whole client's
> > filesystem path which creates a problem when you want to save
> > the file on a server's filesystem.

What if I were storing information in a database, and wanted to preserve the
client's fields, or had some other need for the path?

What guarantee is there that the filename, even without the path, is valid
for the server?  What if the client OS uses a different set of allowable
symbols?  What if I already have a file of that name from another user?
What if ... ?  Simply stripping the path from the name isn't going to
address the problem.

Besides which, this functionality is already in java.io.File:

  import java.io.File;
  public class filename {
      public static void main(String[] args) {
          System.out.println(new File(args[0]).getPath());
          System.out.println(new File(args[0]).getParent());
          System.out.println(new File(args[0]).getName());
      }
  }

  $ /usr/local/java/bin/java -cp . filename "~noel/filename.java"
  ~noel/filename.java
  ~noel
  filename.java
  $ /usr/local/java/bin/java -cp . filename "c:/frodo/filename.java"
  c:/frodo/filename.java
  c:/frodo
  filename.java
  $ /usr/local/java/bin/java -cp . filename "share:/frodo/filename.java"
  share:/frodo/filename.java
  share:/frodo
  filename.java
  $ /usr/local/java/bin/java -cp . filename
"//myserve/share/frodo/filename.java"
  /myserve/share/frodo/filename.java
  /myserve/share/frodo
  filename.java
  $ /usr/local/java/bin/java -cp . filename
"\\myserve/share/frodo/filename.java"
  \myserve/share/frodo/filename.java
  \myserve/share/frodo
  filename.java

OK, so java.io.File has some issues with UNC names on linux.  Let's check
Windows:

  > java -cp . filename "//myserve/share/frodo/filename.java"
  \\myserve\share\frodo\filename.java
  \\myserve\share\frodo
  filename.java

  > java -cp . filename "\\myserve\share\frodo\filename.java"
  \\myserve\share\frodo\filename.java
  \\myserve\share\frodo
  filename.java

Works fine.

	--- Noel


---------------------------------------------------------------------
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