]> source.dussan.org Git - pf4j.git/commitdiff
Fix #202
authorDecebal Suiu <decebal.suiu@gmail.com>
Sat, 17 Mar 2018 15:57:25 +0000 (17:57 +0200)
committerDecebal Suiu <decebal.suiu@gmail.com>
Sat, 17 Mar 2018 15:57:25 +0000 (17:57 +0200)
pf4j/src/main/java/org/pf4j/util/FileUtils.java
pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java

index 6da79e075468d18cb274d2083584797860f65dc2..0d32ee7049a630be41e27d08418991327f145caa 100644 (file)
@@ -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);
         }
 
index ec15500a9ce677afcc4e90ff8622162fa124a6b0..27b4d72539409688efdc6e5eda4eb6a98e897377 100644 (file)
@@ -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<String> getPlugin1Properties() {
         String[] lines = new String[] {
             "plugin.id=test-plugin-1\n"