Issue 276 - patch from pxb1... to fix character encoding issue with CreateProject command slightly modified to preserve request encoding if it has one

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2000 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Tom Morris 2011-02-04 03:15:12 +00:00
parent 5519f61335
commit 06e2487189

View File

@ -97,6 +97,14 @@ public class CreateProjectCommand extends Command {
ProjectManager.singleton.setBusy(true); ProjectManager.singleton.setBusy(true);
try { try {
/*
* Set UTF-8 as request encoding, then ServletFileUpload will use it as default encoding
*/
if (request.getCharacterEncoding() == null) {
request.setCharacterEncoding("UTF-8");
}
/* /*
* The uploaded file is in the POST body as a "file part". If * The uploaded file is in the POST body as a "file part". If
* we call request.getParameter() then the POST body will get * we call request.getParameter() then the POST body will get
@ -150,7 +158,7 @@ public class CreateProjectCommand extends Command {
InputStream stream = item.openStream(); InputStream stream = item.openStream();
if (item.isFormField()) { if (item.isFormField()) {
if (name.equals("raw-text")) { if (name.equals("raw-text")) {
Reader reader = new InputStreamReader(stream,"UTF-8"); Reader reader = new InputStreamReader(stream,request.getCharacterEncoding());
try { try {
internalInvokeImporter(project, new TsvCsvImporter(), metadata, options, reader); internalInvokeImporter(project, new TsvCsvImporter(), metadata, options, reader);
imported = true; imported = true;
@ -158,9 +166,9 @@ public class CreateProjectCommand extends Command {
reader.close(); reader.close();
} }
} else if (name.equals("project-url")) { } else if (name.equals("project-url")) {
url = Streams.asString(stream); url = Streams.asString(stream, request.getCharacterEncoding());
} else { } else {
options.put(name, Streams.asString(stream)); options.put(name, Streams.asString(stream, request.getCharacterEncoding()));
} }
} else { } else {
String fileName = item.getName().toLowerCase(); String fileName = item.getName().toLowerCase();