Merged V2.2 to HEAD

7290: Merged V2.1 to V2.2
      7252: Fix for AR-1829
      7269: Fix for reopened bug AR-1829 - this time handles the fact that request character set is not set when non-JSF authenticator is used


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7292 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-11-05 14:41:03 +00:00
parent df85e65bc7
commit d1e3736bb6
2 changed files with 20 additions and 4 deletions

View File

@@ -26,6 +26,7 @@ package org.alfresco.web.scripts;
import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -33,6 +34,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.jscript.Scopeable;
import org.alfresco.repo.jscript.ScriptNode;
import org.alfresco.repo.jscript.ScriptNode.ScriptContent;
@@ -60,7 +62,9 @@ public class FormData implements Serializable, Scopeable
private Map<String, FormField> fields = null;
private Map<String, String> parameters = null;
private Map<String, ScriptContent> files = null;
private List<FileItem> files = null;
private String encoding = null;
/**
* Construct
*
@@ -146,6 +150,8 @@ public class FormData implements Serializable, Scopeable
{
FileItemFactory factory = new DiskFileItemFactory();
upload = new ServletFileUpload(factory);
encoding = req.getCharacterEncoding();
upload.setHeaderEncoding(encoding);
try
{
List<FileItem> fileItems = upload.parseRequest(req);
@@ -262,8 +268,15 @@ public class FormData implements Serializable, Scopeable
*/
public String getValue()
{
return file.getString();
}
try
{
return (file.isFormField() && encoding != null) ? file.getString(encoding) : file.getString();
}
catch (UnsupportedEncodingException e)
{
throw new AlfrescoRuntimeException("Unable to decode form field", e);
}
}
public String jsGet_value()
{

View File

@@ -104,7 +104,10 @@ public class WebScriptServlet extends HttpServlet
{
if (logger.isDebugEnabled())
logger.debug("Processing request (" + req.getMethod() + ") " + req.getRequestURL() + (req.getQueryString() != null ? "?" + req.getQueryString() : ""));
if (req.getCharacterEncoding() == null)
{
req.setCharacterEncoding("UTF-8");
}
WebScriptRuntime runtime = new WebScriptServletRuntime(registry, serviceRegistry, authenticator, req, res, serverConfig);
runtime.executeScript();
}