Browse Source

Fix #202

pull/205/head
Decebal Suiu 7 years ago
parent
commit
9f60dac684
  1. 2
      pf4j/src/main/java/org/pf4j/util/FileUtils.java
  2. 14
      pf4j/src/test/java/org/pf4j/CompoundPluginDescriptorFinderTest.java

2
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);
}

14
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<String> getPlugin1Properties() {
String[] lines = new String[] {
"plugin.id=test-plugin-1\n"

Loading…
Cancel
Save