From 8efa9a5c2873f0f80b8cc5b0407bc6e3a4db234a Mon Sep 17 00:00:00 2001 From: ray Date: Mon, 13 Oct 2003 17:52:27 +0000 Subject: [PATCH] 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 --- .../samskivert/velocity/InvocationContext.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/velocity/InvocationContext.java b/projects/samskivert/src/java/com/samskivert/velocity/InvocationContext.java index 627715ba..f14fa174 100644 --- a/projects/samskivert/src/java/com/samskivert/velocity/InvocationContext.java +++ b/projects/samskivert/src/java/com/samskivert/velocity/InvocationContext.java @@ -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 // Copyright (C) 2001 Michael Bayne @@ -111,16 +111,19 @@ public class InvocationContext extends VelocityContext */ public String encodeAllParameters () { + StringBuffer buf = new StringBuffer(); Enumeration e = _req.getParameterNames(); - - String url = ""; while (e.hasMoreElements()) { - String param = (String)e.nextElement(); - url += StringUtil.blank(url) ? param : "&" + param; - url += "=" + StringUtil.encode(_req.getParameter(param)); + if (buf.length() > 0) { + buf.append('&'); + } + 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;