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

@@ -27,7 +27,6 @@ package org.alfresco.web.ui.common;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -744,8 +743,7 @@ public final class Utils
// build up the path skipping the first path as it is the root folder
for (int x = 1; x < paths.size(); x++)
{
path.append("/").append(
Utils.replace(URLEncoder.encode(paths.get(x).getName(), "UTF-8"), "+", "%20"));
path.append("/").append(URLEncoder.encode(paths.get(x).getName()));
}
url = path.toString();
}
@@ -757,11 +755,6 @@ public final class Utils
{
// cannot build path if file no longer exists
}
catch (UnsupportedEncodingException encErr)
{
if (logger.isWarnEnabled())
logger.warn("Failed to calculate webdav url for node: " + node.getNodeRef(), encErr);
}
break;
}

View File

@@ -25,7 +25,6 @@
package org.alfresco.web.ui.common.component;
import java.io.IOException;
import java.net.URLEncoder;
import javax.faces.component.UIOutput;
import javax.faces.component.ValueHolder;
@@ -34,6 +33,8 @@ import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.el.ValueBinding;
import org.alfresco.util.URLEncoder;
/**
* Component that simply renders text
*
@@ -139,7 +140,7 @@ public class UIOutputText extends UIOutput
if (isEncodeForJavaScript())
{
out.write( URLEncoder.encode((String)getValue(), "UTF-8").replace('+', ' ') );
out.write( URLEncoder.encode((String)getValue()) );
}
else
{

View File

@@ -25,7 +25,6 @@
package org.alfresco.web.ui.repo.component;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -43,6 +42,7 @@ import javax.faces.el.ValueBinding;
import org.alfresco.config.Config;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.URLEncoder;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.config.ActionsConfigElement;
@@ -451,7 +451,7 @@ public class UIActions extends SelfRenderingComponent
{
// found a Path - encode it as a URL argument
scriptHref.append("?scriptPath=");
scriptHref.append(Utils.replace(URLEncoder.encode(actionDef.Script, "UTF-8"), "+", "%20"));
scriptHref.append(URLEncoder.encode(actionDef.Script));
}
else
{