mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -25,9 +25,7 @@
|
||||
package org.alfresco.web.scripts.bean;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
@@ -37,19 +35,18 @@ import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateException;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.alfresco.util.URLEncoder;
|
||||
import org.alfresco.web.scripts.DeclarativeWebScript;
|
||||
import org.alfresco.web.scripts.WebScriptException;
|
||||
import org.alfresco.web.scripts.WebScriptRequest;
|
||||
import org.alfresco.web.scripts.WebScriptStatus;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
/**
|
||||
@@ -389,19 +386,11 @@ public class KeywordSearch extends DeclarativeWebScript
|
||||
@Override
|
||||
public String getUrl()
|
||||
{
|
||||
try
|
||||
{
|
||||
return MessageFormat.format(URL, new Object[] {
|
||||
getNodeRef().getStoreRef().getProtocol(),
|
||||
getNodeRef().getStoreRef().getIdentifier(),
|
||||
getNodeRef().getId(),
|
||||
StringUtils.replace(URLEncoder.encode(getName(), "UTF-8"), "+", "%20") } );
|
||||
}
|
||||
catch (UnsupportedEncodingException err)
|
||||
{
|
||||
throw new TemplateException("Failed to encode content URL for node: " + getNodeRef(), err);
|
||||
}
|
||||
return MessageFormat.format(URL, new Object[] {
|
||||
getNodeRef().getStoreRef().getProtocol(),
|
||||
getNodeRef().getStoreRef().getIdentifier(),
|
||||
getNodeRef().getId(),
|
||||
URLEncoder.encode(getName()) } );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -28,12 +28,12 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.Writer;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import javax.faces.component.UIForm;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.util.URLEncoder;
|
||||
import org.alfresco.web.scripts.WebScriptCache;
|
||||
import org.alfresco.web.scripts.WebScriptResponse;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
@@ -81,14 +81,7 @@ public class WebScriptJSFResponse implements WebScriptResponse
|
||||
buf.append("'].value=");
|
||||
buf.append("'");
|
||||
// encode the URL to the webscript
|
||||
try
|
||||
{
|
||||
buf.append(URLEncoder.encode(url, "UTF-8"));
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to utf-8 encode script url.");
|
||||
}
|
||||
buf.append(URLEncoder.encode(url));
|
||||
buf.append("'");
|
||||
buf.append(";");
|
||||
|
||||
|
Reference in New Issue
Block a user