mschachter 01/05/09 17:56:54
Modified: src/share/org/apache/struts/upload
DiskMultipartRequestHandler.java
MultipartIterator.java
Log:
- Modified DiskMultipartRequestHandler to attempt to retrieve the value of
the ServletContext attribute "javax.servlet.context.tempdir" before
all other possible temporary directories specified
- Fixed bug in MultipartIterator that incorrectly parsed filenames from
windows file server
Revision Changes Path
1.9 +14 -14
jakarta-struts/src/share/org/apache/struts/upload/DiskMultipartRequestHandler.java
Index: DiskMultipartRequestHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/upload/DiskMultipartRequestHandler.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DiskMultipartRequestHandler.java 2001/04/11 22:56:19 1.8
+++ DiskMultipartRequestHandler.java 2001/05/10 00:56:54 1.9
@@ -192,20 +192,20 @@
* property, or a system property, in that order
*/
protected void retrieveTempDir() {
- //get a handle to some temporary file and open
- //a stream to it
- tempDir = servlet.getTempDir();
- if (tempDir == null) {
- //attempt to retrieve the servlet container's temporary directory
- ServletContext context = servlet.getServletConfig().getServletContext();
-
- try {
- tempDir = (String)
context.getAttribute("javax.servlet.context.tempdir");
- }
- catch (ClassCastException cce) {
- tempDir = ((File)
context.getAttribute("javax.servlet.context.tempdir")).getAbsolutePath();
- }
-
+
+ //attempt to retrieve the servlet container's temporary directory
+ ServletContext context = servlet.getServletConfig().getServletContext();
+
+ try {
+ tempDir = (String)
context.getAttribute("javax.servlet.context.tempdir");
+ }
+ catch (ClassCastException cce) {
+ tempDir = ((File)
context.getAttribute("javax.servlet.context.tempdir")).getAbsolutePath();
+ }
+
+ if (tempDir == null) {
+ //attempt to retrieve the temporary directory from the controller
+ tempDir = servlet.getTempDir();
if (tempDir == null) {
//default to system-wide tempdir
1.13 +4 -0
jakarta-struts/src/share/org/apache/struts/upload/MultipartIterator.java
Index: MultipartIterator.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/upload/MultipartIterator.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- MultipartIterator.java 2001/04/18 14:21:20 1.12
+++ MultipartIterator.java 2001/05/10 00:56:54 1.13
@@ -182,6 +182,10 @@
//from linux jdk's the entire filepath
//isn't parsed correctly from File.getName()
int colonIndex = filename.indexOf(":");
+ if (colonIndex == -1) {
+ //check for Window's SMB server file paths
+ colonIndex = filename.indexOf("\\\\");
+ }
int slashIndex = filename.lastIndexOf("\\");
if ((colonIndex > -1) && (slashIndex > -1)) {