From fb73d289ece772aa4048bf01d80d3065709b39d3 Mon Sep 17 00:00:00 2001 From: wangf1122 <74916635+wangf1122@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:37:56 -0500 Subject: [PATCH] Url decode the resourceId supplied to store.getResourceInternal to fix filenames containing spaces. (#8581) (#8587) Co-authored-by: Ian --- core/src/main/java/org/fao/geonet/util/XslUtil.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/fao/geonet/util/XslUtil.java b/core/src/main/java/org/fao/geonet/util/XslUtil.java index 5136b2f3882..569e7a0b588 100644 --- a/core/src/main/java/org/fao/geonet/util/XslUtil.java +++ b/core/src/main/java/org/fao/geonet/util/XslUtil.java @@ -55,8 +55,8 @@ import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.fao.geonet.ApplicationContextHolder; +import org.fao.geonet.Constants; import org.fao.geonet.SystemInfo; -import org.fao.geonet.api.records.attachments.FilesystemStore; import org.fao.geonet.api.records.attachments.FilesystemStoreResourceContainer; import org.fao.geonet.api.records.attachments.Store; import org.fao.geonet.constants.Geonet; @@ -122,6 +122,7 @@ import java.io.StringReader; import java.net.URL; import java.net.URLConnection; +import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.*; @@ -1257,9 +1258,9 @@ public static String buildDataUrl(String url, Integer size) { if (m.find()) { Store store = ApplicationContextHolder.get().getBean("filesystemStore", Store.class); try (Store.ResourceHolder file = store.getResourceInternal( - m.group(1), + URLDecoder.decode(m.group(1), Constants.ENCODING), MetadataResourceVisibility.PUBLIC, - m.group(2), true)) { + URLDecoder.decode(m.group(2), Constants.ENCODING), true)) { image = ImageIO.read(file.getPath().toFile()); } } else {