Skip to content

Commit 89ea341

Browse files
Again, fix #61 by properly decoding file paths
1 parent 1c4fce7 commit 89ea341

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

plugman-core/src/main/java/core/com/rylinaux/plugman/util/updatechecker/CurseForgeUtil.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
import java.io.File;
4141
import java.io.IOException;
4242
import java.net.URI;
43+
import java.net.URLDecoder;
4344
import java.net.http.HttpClient;
4445
import java.net.http.HttpRequest;
4546
import java.net.http.HttpResponse;
47+
import java.nio.charset.StandardCharsets;
4648
import java.time.Duration;
4749
import java.util.Map;
4850
import java.util.TreeMap;
@@ -121,7 +123,13 @@ public static UpdateResult checkUpToDate(String pluginName, Long pluginId, Plugi
121123

122124
var file = plugin.getFile();
123125
// Fetch file manually, not sure why `Plugin#getFile` can fail in the first place, tbh
124-
if (file == null) file = new File(plugin.getClass().getProtectionDomain().getCodeSource().getLocation().getFile());
126+
if (file == null) {
127+
var path = plugin.getClass()
128+
.getProtectionDomain().getCodeSource()
129+
.getLocation().getFile();
130+
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
131+
file = new File(path);
132+
}
125133
try {
126134
currentPluginHashCode = Files.asByteSource(file).hash(Hashing.md5());
127135
} catch (IOException e) {

0 commit comments

Comments
 (0)