Support export filenames with non-ASCII chars. (fixes #3724) (#3736)

Co-authored-by: Douglas Mennella <douglas.mennella@gmail.com>
This commit is contained in:
gitonthescene 2021-03-17 16:28:21 +09:00 committed by GitHub
parent b8475ca7be
commit 5bbc4ae304
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,6 +58,7 @@ import com.google.refine.exporters.StreamExporter;
import com.google.refine.exporters.WriterExporter;
import com.google.refine.exporters.sql.SqlExporterException;
import com.google.refine.model.Project;
import com.google.common.net.PercentEscaper;
public class ExportRowsCommand extends Command {
private static final Logger logger = LoggerFactory.getLogger("ExportRowsCommand");
@ -105,7 +106,9 @@ public class ExportRowsCommand extends Command {
if (!"true".equals(preview)) {
String path = request.getPathInfo();
String filename = path.substring(path.lastIndexOf('/') + 1);
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
PercentEscaper escaper = new PercentEscaper("", false);
filename = escaper.escape(filename);
response.setHeader("Content-Disposition", "attachment; filename=" +filename+"; filename*=utf-8' '" + filename);
}
if (exporter instanceof WriterExporter) {