mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge pull request #2138 from Alfresco/MNT-23476_UNZIP_FILENAME_ACCENT
MNT-23476 Unable to unzip files in Share if it contains a document with a filename containing an accent
This commit is contained in:
@@ -44,7 +44,6 @@ import java.util.zip.ZipException;
|
|||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ApplicationModel;
|
import org.alfresco.model.ApplicationModel;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.action.ActionServiceImpl;
|
|
||||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.importer.ACPImportPackageHandler;
|
import org.alfresco.repo.importer.ACPImportPackageHandler;
|
||||||
@@ -66,8 +65,7 @@ import org.alfresco.util.TempFileProvider;
|
|||||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||||
import org.apache.commons.compress.archivers.zip.ZipFile;
|
import org.apache.commons.compress.archivers.zip.ZipFile;
|
||||||
import org.apache.commons.compress.utils.InputStreamStatistics;
|
import org.apache.commons.compress.utils.InputStreamStatistics;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Importer action executor
|
* Importer action executor
|
||||||
@@ -76,7 +74,6 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
*/
|
*/
|
||||||
public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
||||||
{
|
{
|
||||||
private static Log logger = LogFactory.getLog(ImporterActionExecuter.class);
|
|
||||||
public static final String NAME = "import";
|
public static final String NAME = "import";
|
||||||
public static final String PARAM_ENCODING = "encoding";
|
public static final String PARAM_ENCODING = "encoding";
|
||||||
public static final String PARAM_DESTINATION_FOLDER = "destination";
|
public static final String PARAM_DESTINATION_FOLDER = "destination";
|
||||||
@@ -246,22 +243,18 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
|||||||
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807
|
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807
|
||||||
// We also try to use the extra encoding information if present
|
// We also try to use the extra encoding information if present
|
||||||
String encoding = (String) ruleAction.getParameterValue(PARAM_ENCODING);
|
String encoding = (String) ruleAction.getParameterValue(PARAM_ENCODING);
|
||||||
logger.info("Encoding before: "+encoding);
|
|
||||||
if (encoding == null)
|
if (encoding == null)
|
||||||
{
|
{
|
||||||
logger.info("Encoding is null ");
|
encoding = "UTF-8";
|
||||||
encoding = "Cp437";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (encoding.equalsIgnoreCase("default"))
|
if (encoding.equalsIgnoreCase("default"))
|
||||||
{
|
{
|
||||||
logger.info("Encoding is default ");
|
encoding = null;
|
||||||
encoding = "Cp437";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info("Encoding after: "+encoding);
|
zipFile = new ZipFile(tempFile, encoding, false);
|
||||||
zipFile = new ZipFile(tempFile, encoding, true);
|
|
||||||
// build a temp dir name based on the ID of the noderef we are importing
|
// build a temp dir name based on the ID of the noderef we are importing
|
||||||
// also use the long life temp folder as large ZIP files can take a while
|
// also use the long life temp folder as large ZIP files can take a while
|
||||||
File alfTempDir = TempFileProvider.getLongLifeTempDir("import");
|
File alfTempDir = TempFileProvider.getLongLifeTempDir("import");
|
||||||
@@ -414,7 +407,7 @@ public class ImporterActionExecuter extends ActionExecuterAbstractBase
|
|||||||
ZipArchiveEntry entry = e.nextElement();
|
ZipArchiveEntry entry = e.nextElement();
|
||||||
if (!entry.isDirectory())
|
if (!entry.isDirectory())
|
||||||
{
|
{
|
||||||
fileName = entry.getName();
|
fileName = StringUtils.stripAccents(entry.getName()).replaceAll("\\?","_");
|
||||||
fileName = fileName.replace('/', File.separatorChar);
|
fileName = fileName.replace('/', File.separatorChar);
|
||||||
|
|
||||||
if (fileName.startsWith("/") || fileName.indexOf(":" + File.separator) == 1 || fileName.contains(".." + File.separator))
|
if (fileName.startsWith("/") || fileName.indexOf(":" + File.separator) == 1 || fileName.contains(".." + File.separator))
|
||||||
|
Reference in New Issue
Block a user