From efc337a8706887ad2908da314b844f59890ddce0 Mon Sep 17 00:00:00 2001
From: gpawel <gpawel>
Date: Wed, 19 Oct 2011 15:29:20 +0000
Subject: [PATCH] LMS-2578 Attachments names with special characters can not be
 downloaded or deleted

SVN: 23349
---
 .../attachment/AttachmentListDeletionConfirmationDialog.java  | 4 +++-
 .../generic/client/web/server/AttachmentDownloadServlet.java  | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/attachment/AttachmentListDeletionConfirmationDialog.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/attachment/AttachmentListDeletionConfirmationDialog.java
index f5a61324cf5..8196175b7d4 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/attachment/AttachmentListDeletionConfirmationDialog.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/attachment/AttachmentListDeletionConfirmationDialog.java
@@ -26,6 +26,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAs
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.AbstractDataListPermanentDeletionConfirmationDialog;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.lang.StringEscapeUtils;
 import ch.systemsx.cisd.openbis.generic.shared.basic.IAttachmentHolder;
 import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AttachmentVersions;
@@ -72,7 +73,8 @@ public final class AttachmentListDeletionConfirmationDialog
         List<String> fileNames = new ArrayList<String>();
         for (TableModelRowWithObject<AttachmentVersions> attachmentVersion : attachmentVersions)
         {
-            fileNames.add(attachmentVersion.getObjectOrNull().getCurrent().getFileName());
+            fileNames.add(StringEscapeUtils.unescapeHtml(attachmentVersion.getObjectOrNull()
+                    .getCurrent().getFileName()));
         }
         return fileNames;
     }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/AttachmentDownloadServlet.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/AttachmentDownloadServlet.java
index 2ee4caa605d..5a2a9ae3845 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/AttachmentDownloadServlet.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/server/AttachmentDownloadServlet.java
@@ -28,6 +28,7 @@ import org.springframework.web.servlet.mvc.AbstractCommandController;
 
 import ch.rinn.restrictions.Private;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericConstants;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.lang.StringEscapeUtils;
 import ch.systemsx.cisd.openbis.generic.client.web.server.AbstractFileDownloadServlet;
 import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AttachmentHolderKind;
@@ -77,7 +78,7 @@ public class AttachmentDownloadServlet extends AbstractFileDownloadServlet
         {
             encoding = "ISO-8859-1";
         }
-        final String fileName = URLDecoder.decode(name, encoding);
+        final String fileName = StringEscapeUtils.unescapeHtml(URLDecoder.decode(name, encoding));
         final String techIdString = request.getParameter(GenericConstants.TECH_ID_PARAMETER);
         final String attachmentHolderKind =
                 request.getParameter(GenericConstants.ATTACHMENT_HOLDER_PARAMETER);
-- 
GitLab