mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +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:
@@ -24,10 +24,10 @@
|
||||
*/
|
||||
package org.alfresco.repo.template;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.util.URLEncoder;
|
||||
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import freemarker.template.TemplateScalarModel;
|
||||
@@ -55,18 +55,7 @@ public class UrlEncodeMethod extends BaseTemplateProcessorExtension implements T
|
||||
Object arg0 = args.get(0);
|
||||
if (arg0 instanceof TemplateScalarModel)
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: Support other encodings, although
|
||||
// http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLEncoder.html
|
||||
// recommends UTF-8
|
||||
result = URLEncoder.encode(((TemplateScalarModel)arg0).getAsString(), "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
// fallback to original url
|
||||
result = ((TemplateScalarModel)arg0).getAsString();
|
||||
}
|
||||
result = URLEncoder.encode(((TemplateScalarModel)arg0).getAsString());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user