URL encode the parameter names as well as the values, use a StringBuffer.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@1261 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2003-10-13 17:52:27 +00:00
parent c10358e7a6
commit 8efa9a5c28
@@ -1,5 +1,5 @@
// //
// $Id: InvocationContext.java,v 1.4 2003/10/13 17:40:10 eric Exp $ // $Id: InvocationContext.java,v 1.5 2003/10/13 17:52:27 ray Exp $
// //
// samskivert library - useful routines for java programs // samskivert library - useful routines for java programs
// Copyright (C) 2001 Michael Bayne // Copyright (C) 2001 Michael Bayne
@@ -111,16 +111,19 @@ public class InvocationContext extends VelocityContext
*/ */
public String encodeAllParameters () public String encodeAllParameters ()
{ {
StringBuffer buf = new StringBuffer();
Enumeration e = _req.getParameterNames(); Enumeration e = _req.getParameterNames();
String url = "";
while (e.hasMoreElements()) { while (e.hasMoreElements()) {
String param = (String)e.nextElement(); if (buf.length() > 0) {
url += StringUtil.blank(url) ? param : "&" + param; buf.append('&');
url += "=" + StringUtil.encode(_req.getParameter(param)); }
String param = (String) e.nextElement();
buf.append(StringUtil.encode(param));
buf.append('=');
buf.append(StringUtil.encode(_req.getParameter(param)));
} }
return url; return buf.toString();
} }
protected HttpServletRequest _req; protected HttpServletRequest _req;