diff --git a/pf4j/src/main/java/org/pf4j/util/FileUtils.java b/pf4j/src/main/java/org/pf4j/util/FileUtils.java index 6da79e0..0d32ee7 100644 --- a/pf4j/src/main/java/org/pf4j/util/FileUtils.java +++ b/pf4j/src/main/java/org/pf4j/util/FileUtils.java @@ -219,6 +219,8 @@ public class FileUtils { String pathString = path.toString(); // transformation for Windows OS pathString = StringUtils.addStart(pathString.replace("\\", "/"), "/"); + // space is replaced with %20 + pathString = pathString.replaceAll(" ","%20"); uri = URI.create("jar:file:" + pathString); } diff --git a/pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java b/pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java index ec15500..27b4d72 100644 --- a/pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java +++ b/pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java @@ -20,6 +20,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.pf4j.plugin.PluginZip; +import java.io.File; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -80,6 +81,19 @@ public class CompoundPluginDescriptorFinderTest { instance.find(getPluginsRoot().resolve("test-plugin-3")); } + @Test + public void testSpaceCharacterInFileName() throws Exception { + PluginDescriptorFinder instance = new PropertiesPluginDescriptorFinder(); + File jar = testFolder.newFile("my plugin-1.2.3.jar"); + + PluginZip pluginJar = new PluginZip.Builder(jar, "myPlugin") + .pluginVersion("1.2.3") + .build(); + + PluginDescriptor pluginDescriptor = instance.find(pluginJar.path()); + assertNotNull(pluginDescriptor); + } + private List getPlugin1Properties() { String[] lines = new String[] { "plugin.id=test-plugin-1\n"