Sanitising of all java.net.URLEncoder class usage to use a proper UTF-8 URL encoder.

Since URLEncoder is actually an HTML form encoder - not really for URI encoding - and it requires an extra step (converting '+' to %20)
Replaced with w3 Consortium algorithm for fast UTF-8 URL encoding in a single step (rather than using the cludgy and slow URI core java classes)
Addition of Template API for generate URLs to node content download webscript API: node.serviceUrl

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7316 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-11-09 14:59:59 +00:00
parent 3e03d87285
commit 1439ded6e0
8 changed files with 50 additions and 84 deletions

View File

@@ -35,7 +35,6 @@ import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -57,6 +56,7 @@ import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.util.URLEncoder;
import org.alfresco.web.scripts.WebScriptCache;
import org.alfresco.web.scripts.WebScriptMatch;
import org.alfresco.web.scripts.WebScriptRequest;
@@ -636,15 +636,8 @@ public class PageRendererServlet extends WebScriptServlet
{
// encode to allow presentation tier webscripts to call themselves non this page
// needs the servlet URL plus args to identify the webscript and it's new url
try
{
return context.RequestPath + context.RequestURI + "?" + PARAM_COMPONENT_URL + "=" +
URLEncoder.encode(url, "UTF-8") + "&" + PARAM_COMPONENT_ID + "=" + componentId;
}
catch (UnsupportedEncodingException err)
{
throw new AlfrescoRuntimeException("Unable to encode UTF-8 format URL: " + url);
}
return context.RequestPath + context.RequestURI + "?" + PARAM_COMPONENT_URL + "=" +
URLEncoder.encode(url) + "&" + PARAM_COMPONENT_ID + "=" + componentId;
}
public String getEncodeScriptUrlFunction(String name)