1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2024-11-27 12:46:22 +01:00

Always use proper local libraries folder path

There were a couple places where I relied on the manifest to have
the default libraries location of "libraries"; this commit fixes those
instances. Without this fix it would be possible for a custom libraries
URL path to leak into the local filesystem, which might've mucked
something up.
This commit is contained in:
Henry Le Grys 2021-09-04 00:34:09 +01:00
parent 215b7871e7
commit 5c3768f1cf
3 changed files with 7 additions and 7 deletions

View File

@ -86,7 +86,7 @@ public class OldForgeLoaderProcessor implements ILoaderProcessor {
ZipEntry libraryEntry = BuilderUtils.getZipEntry(jarFile, filePath);
if (libraryEntry != null) {
File librariesDir = new File(baseDir, manifest.getLibrariesLocation());
File librariesDir = new File(baseDir, "libraries");
File extractPath = new File(librariesDir, Library.mavenNameToPath(libraryPath));
Files.createParentDirs(extractPath);

View File

@ -44,12 +44,12 @@ public class ProcessorTask implements InstallTask {
VersionManifest versionManifest = manifest.getVersionManifest();
LoaderSubResolver resolver = new LoaderSubResolver(manifest, loaderManifest,
Environment.getInstance(), Side.CLIENT, launcher.getBaseDir(), localFiles);
Environment.getInstance(), Side.CLIENT, launcher.getLibrariesDir(), localFiles);
Map<String, SidedData<String>> sidedData = loaderManifest.getSidedData();
sidedData.put("ROOT", SidedData.of(launcher.getInstallerDir().getAbsolutePath()));
sidedData.put("MINECRAFT_JAR", SidedData.of(launcher.getJarPath(versionManifest).getAbsolutePath()));
sidedData.put("LIBRARY_DIR", SidedData.of(resolver.getPathOf(manifest.getLibrariesLocation())));
sidedData.put("LIBRARY_DIR", SidedData.of(launcher.getLibrariesDir().getAbsolutePath()));
sidedData.put("MINECRAFT_VERSION", SidedData.of(versionManifest.getId()));
message = "Resolving parameters";

View File

@ -17,11 +17,11 @@ public class LoaderSubResolver implements Function<String, String> {
private final LoaderManifest loader;
private final Environment env;
private final Side side;
private final File baseDir;
private final File libraryDir;
private final HashMap<String, DownloadableFile.LocalFile> localFiles;
public String getPathOf(String... rest) {
File file = baseDir;
File file = libraryDir;
for (String part : rest) {
file = new File(file, part);
}
@ -49,9 +49,9 @@ public class LoaderSubResolver implements Function<String, String> {
String libraryName = arg.substring(1, bound);
Library library = loader.findLibrary(libraryName);
if (library != null) {
arg = getPathOf(manifest.getLibrariesLocation(), library.getPath(env));
arg = getPathOf(library.getPath(env));
} else {
arg = getPathOf(manifest.getLibrariesLocation(), Library.mavenNameToPath(libraryName));
arg = getPathOf(Library.mavenNameToPath(libraryName));
}
} else if (start == '&' && end == '&') {
String localFileName = arg.substring(1, bound);