JETTY-1121 Merge Multipart query parameters

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@993 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2009-10-16 00:14:38 +00:00
parent b5d16898e5
commit 298182f737
3 changed files with 51 additions and 39 deletions

View File

@ -1,24 +1,25 @@
jetty-7.0.1-SNAPSHOT jetty-7.0.1-SNAPSHOT
+ Refactored continuation test harnessess
+ Continuations ISE rather than ignore bad transitions
+ Improved start.jar usage text for properties
+ Promoted Jetty WebApp Verifier from Sandbox
+ Promoted Jetty Centralized Logging from Sandbox
+ 274251 DefaultServlet supports exact match mode. + 274251 DefaultServlet supports exact match mode.
+ 288401 HttpExchange.cancel() Method Unimplemented + 288401 HttpExchange.cancel() Method Unimplemented
+ 289265 Test harness for async input
+ 289027 deobfuscate HttpClient SSL passwords + 289027 deobfuscate HttpClient SSL passwords
+ 289265 Test harness for async input
+ 289959 Improved ContextDeployer configuration + 289959 Improved ContextDeployer configuration
+ 289960 start.jar assumes command line args are configs + 289960 start.jar assumes command line args are configs
+ JETTY-937 More JVM bug work arounds. Insert pause if all else fails
+ JETTY-1114 unsynchronised WebAppClassloader.getResource(String)
+ JETTY-1122 Handle multi-byte utf that causes buffer overflow
+ JETTY-1129 Filter control characters out of StdErrLog
+ Fixed XSS issue in CookieDump demo servlet.
+ 291019 Fix default DEBUG option; "-D.DEBUG=true" now works + 291019 Fix default DEBUG option; "-D.DEBUG=true" now works
+ 291340 Race condition in onException() notifications + 291340 Race condition in onException() notifications
+ 291543 make bin/*.sh scripts executable in distribution + 291543 make bin/*.sh scripts executable in distribution
+ 291589 Update jetty-rewrite demo + 291589 Update jetty-rewrite demo
+ JETTY-937 More JVM bug work arounds. Insert pause if all else fails
+ JETTY-1114 unsynchronised WebAppClassloader.getResource(String)
+ JETTY-1121 Merge Multipart query parameters
+ JETTY-1122 Handle multi-byte utf that causes buffer overflow
+ JETTY-1129 Filter control characters out of StdErrLog
+ Continuations ISE rather than ignore bad transitions
+ Fixed XSS issue in CookieDump demo servlet.
+ Improved start.jar usage text for properties
+ Promoted Jetty Centralized Logging from Sandbox
+ Promoted Jetty WebApp Verifier from Sandbox
+ Refactored continuation test harnessess
jetty-7.0.0.v20091005 5 October 2009 jetty-7.0.0.v20091005 5 October 2009
291340 Race condition in onException() notifications 291340 Race condition in onException() notifications

View File

@ -38,6 +38,7 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletRequestWrapper;
import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.MultiMap; import org.eclipse.jetty.util.MultiMap;
import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.TypeUtil;
@ -101,16 +102,17 @@ public class MultiPartFilter implements Filter
String boundary="--"+value(content_type.substring(content_type.indexOf("boundary="))); String boundary="--"+value(content_type.substring(content_type.indexOf("boundary=")));
byte[] byteBoundary=(boundary+"--").getBytes(StringUtil.__ISO_8859_1); byte[] byteBoundary=(boundary+"--").getBytes(StringUtil.__ISO_8859_1);
// cross-container
MultiMap params = new MultiMap(request.getParameterMap());
// jetty-specific but more efficient MultiMap params = new MultiMap();
/*MultiMap params = new MultiMap(); for (Iterator i = request.getParameterMap().entrySet().iterator();i.hasNext();)
if(srequest instanceof org.eclipse.jetty.server.Request)
{ {
org.eclipse.jetty.server.Request req = ((org.eclipse.jetty.server.Request)srequest); Map.Entry entry=(Map.Entry)i.next();
req.getUri().decodeQueryTo(params, req.getQueryEncoding()); Object value=entry.getValue();
}*/ if (value instanceof String[])
params.addValues(entry.getKey(),(String[])value);
else
params.add(entry.getKey(),value);
}
try try
{ {
@ -193,7 +195,7 @@ public class MultiPartFilter implements Filter
if(_fileOutputBuffer>0) if(_fileOutputBuffer>0)
out = new BufferedOutputStream(out, _fileOutputBuffer); out = new BufferedOutputStream(out, _fileOutputBuffer);
request.setAttribute(name,file); request.setAttribute(name,file);
params.put(name, filename); params.add(name, filename);
if (_deleteFiles) if (_deleteFiles)
{ {
@ -319,6 +321,7 @@ public class MultiPartFilter implements Filter
} }
} }
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
private String value(String nameEqualsValue) private String value(String nameEqualsValue)
{ {
@ -346,11 +349,13 @@ public class MultiPartFilter implements Filter
public void destroy() public void destroy()
{ {
} }
/* ------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------- */
private static class Wrapper extends HttpServletRequestWrapper private static class Wrapper extends HttpServletRequestWrapper
{ {
String encoding="UTF-8"; String _encoding=StringUtil.__UTF8;
MultiMap map; MultiMap _params;
/* ------------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- */
/** Constructor. /** Constructor.
@ -359,13 +364,14 @@ public class MultiPartFilter implements Filter
public Wrapper(HttpServletRequest request, MultiMap map) public Wrapper(HttpServletRequest request, MultiMap map)
{ {
super(request); super(request);
this.map=map; this._params=map;
} }
/* ------------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- */
/** /**
* @see javax.servlet.ServletRequest#getContentLength() * @see javax.servlet.ServletRequest#getContentLength()
*/ */
@Override
public int getContentLength() public int getContentLength()
{ {
return 0; return 0;
@ -375,14 +381,18 @@ public class MultiPartFilter implements Filter
/** /**
* @see javax.servlet.ServletRequest#getParameter(java.lang.String) * @see javax.servlet.ServletRequest#getParameter(java.lang.String)
*/ */
@Override
public String getParameter(String name) public String getParameter(String name)
{ {
Object o=map.get(name); Object o=_params.get(name);
if (!(o instanceof byte[]) && LazyList.size(o)>0)
o=LazyList.get(o,0);
if (o instanceof byte[]) if (o instanceof byte[])
{ {
try try
{ {
String s=new String((byte[])o,encoding); String s=new String((byte[])o,_encoding);
return s; return s;
} }
catch(Exception e) catch(Exception e)
@ -390,13 +400,8 @@ public class MultiPartFilter implements Filter
e.printStackTrace(); e.printStackTrace();
} }
} }
else if (o instanceof String) else if (o!=null)
return (String)o; return String.valueOf(o);
else if (o instanceof String[])
{
String[] s = (String[])o;
return s.length>0 ? s[0] : null;
}
return null; return null;
} }
@ -404,27 +409,30 @@ public class MultiPartFilter implements Filter
/** /**
* @see javax.servlet.ServletRequest#getParameterMap() * @see javax.servlet.ServletRequest#getParameterMap()
*/ */
@Override
public Map getParameterMap() public Map getParameterMap()
{ {
return map; return Collections.unmodifiableMap(_params.toStringArrayMap());
} }
/* ------------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- */
/** /**
* @see javax.servlet.ServletRequest#getParameterNames() * @see javax.servlet.ServletRequest#getParameterNames()
*/ */
@Override
public Enumeration getParameterNames() public Enumeration getParameterNames()
{ {
return Collections.enumeration(map.keySet()); return Collections.enumeration(_params.keySet());
} }
/* ------------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- */
/** /**
* @see javax.servlet.ServletRequest#getParameterValues(java.lang.String) * @see javax.servlet.ServletRequest#getParameterValues(java.lang.String)
*/ */
@Override
public String[] getParameterValues(String name) public String[] getParameterValues(String name)
{ {
List l=map.getValues(name); List l=_params.getValues(name);
if (l==null || l.size()==0) if (l==null || l.size()==0)
return new String[0]; return new String[0];
String[] v = new String[l.size()]; String[] v = new String[l.size()];
@ -435,7 +443,7 @@ public class MultiPartFilter implements Filter
{ {
try try
{ {
v[i]=new String((byte[])o,encoding); v[i]=new String((byte[])o,_encoding);
} }
catch(Exception e) catch(Exception e)
{ {
@ -452,10 +460,11 @@ public class MultiPartFilter implements Filter
/** /**
* @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String) * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String)
*/ */
@Override
public void setCharacterEncoding(String enc) public void setCharacterEncoding(String enc)
throws UnsupportedEncodingException throws UnsupportedEncodingException
{ {
encoding=enc; _encoding=enc;
} }
} }
} }

View File

@ -740,7 +740,9 @@ public class Dump extends HttpServlet
pout.write("<br/>"); pout.write("<br/>");
pout.write("<h2>Form to generate UPLOAD content</h2>"); pout.write("<h2>Form to generate UPLOAD content</h2>");
pout.write("<form method=\"POST\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" action=\""+response.encodeURL(getURI(request))+"\">"); pout.write("<form method=\"POST\" enctype=\"multipart/form-data\" accept-charset=\"utf-8\" action=\""+
response.encodeURL(getURI(request))+(request.getQueryString()==null?"":("?"+request.getQueryString()))+
"\">");
pout.write("TextField: <input type=\"text\" name=\"TextField\" value=\"comment\"/><br/>\n"); pout.write("TextField: <input type=\"text\" name=\"TextField\" value=\"comment\"/><br/>\n");
pout.write("File 1: <input type=\"file\" name=\"file1\" /><br/>\n"); pout.write("File 1: <input type=\"file\" name=\"file1\" /><br/>\n");
pout.write("File 2: <input type=\"file\" name=\"file2\" /><br/>\n"); pout.write("File 2: <input type=\"file\" name=\"file2\" /><br/>\n");