Revision: 767
http://stripes.svn.sourceforge.net/stripes/?rev=767&view=rev
Author: bengunter
Date: 2008-01-19 14:39:24 -0800 (Sat, 19 Jan 2008)
Log Message:
-----------
Fixed STS-478. CommonsMultipartWrapper.getFileParameterValue(String) now
returns null if the FileItem is null or if the FileItem's name is null or empty
and its size is zero.
Modified Paths:
--------------
trunk/stripes/src/net/sourceforge/stripes/controller/multipart/CommonsMultipartWrapper.java
Modified:
trunk/stripes/src/net/sourceforge/stripes/controller/multipart/CommonsMultipartWrapper.java
===================================================================
---
trunk/stripes/src/net/sourceforge/stripes/controller/multipart/CommonsMultipartWrapper.java
2008-01-19 22:14:42 UTC (rev 766)
+++
trunk/stripes/src/net/sourceforge/stripes/controller/multipart/CommonsMultipartWrapper.java
2008-01-19 22:39:24 UTC (rev 767)
@@ -149,24 +149,24 @@
*/
public FileBean getFileParameterValue(String name) {
final FileItem item = this.files.get(name);
- if (item == null) {
+ String filename = item.getName();
+ if (item == null || ((filename == null || filename.length() == 0) &&
item.getSize() == 0)) {
return null;
}
else {
// Attempt to ensure the file name is just the basename with no
path included
- String basename = item.getName();
int index;
- if (WINDOWS_PATH_PREFIX_PATTERN.matcher(basename).find())
- index = basename.lastIndexOf('\\');
+ if (WINDOWS_PATH_PREFIX_PATTERN.matcher(filename).find())
+ index = filename.lastIndexOf('\\');
else
- index = basename.lastIndexOf('/');
- if (index >= 0 && index + 1 < basename.length() - 1)
- basename = basename.substring(index + 1);
+ index = filename.lastIndexOf('/');
+ if (index >= 0 && index + 1 < filename.length() - 1)
+ filename = filename.substring(index + 1);
// Use an anonymous inner subclass of FileBean that overrides all
the
// methods that rely on having a File present, to use the FileItem
// created by commons upload instead.
- return new FileBean(null, item.getContentType(), basename,
this.charset) {
+ return new FileBean(null, item.getContentType(), filename,
this.charset) {
@Override public long getSize() { return item.getSize(); }
@Override public InputStream getInputStream() throws
IOException {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development