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:
parent
215b7871e7
commit
5c3768f1cf
@ -86,7 +86,7 @@ public class OldForgeLoaderProcessor implements ILoaderProcessor {
|
|||||||
ZipEntry libraryEntry = BuilderUtils.getZipEntry(jarFile, filePath);
|
ZipEntry libraryEntry = BuilderUtils.getZipEntry(jarFile, filePath);
|
||||||
|
|
||||||
if (libraryEntry != null) {
|
if (libraryEntry != null) {
|
||||||
File librariesDir = new File(baseDir, manifest.getLibrariesLocation());
|
File librariesDir = new File(baseDir, "libraries");
|
||||||
File extractPath = new File(librariesDir, Library.mavenNameToPath(libraryPath));
|
File extractPath = new File(librariesDir, Library.mavenNameToPath(libraryPath));
|
||||||
|
|
||||||
Files.createParentDirs(extractPath);
|
Files.createParentDirs(extractPath);
|
||||||
|
@ -44,12 +44,12 @@ public class ProcessorTask implements InstallTask {
|
|||||||
VersionManifest versionManifest = manifest.getVersionManifest();
|
VersionManifest versionManifest = manifest.getVersionManifest();
|
||||||
|
|
||||||
LoaderSubResolver resolver = new LoaderSubResolver(manifest, loaderManifest,
|
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();
|
Map<String, SidedData<String>> sidedData = loaderManifest.getSidedData();
|
||||||
sidedData.put("ROOT", SidedData.of(launcher.getInstallerDir().getAbsolutePath()));
|
sidedData.put("ROOT", SidedData.of(launcher.getInstallerDir().getAbsolutePath()));
|
||||||
sidedData.put("MINECRAFT_JAR", SidedData.of(launcher.getJarPath(versionManifest).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()));
|
sidedData.put("MINECRAFT_VERSION", SidedData.of(versionManifest.getId()));
|
||||||
|
|
||||||
message = "Resolving parameters";
|
message = "Resolving parameters";
|
||||||
|
@ -17,11 +17,11 @@ public class LoaderSubResolver implements Function<String, String> {
|
|||||||
private final LoaderManifest loader;
|
private final LoaderManifest loader;
|
||||||
private final Environment env;
|
private final Environment env;
|
||||||
private final Side side;
|
private final Side side;
|
||||||
private final File baseDir;
|
private final File libraryDir;
|
||||||
private final HashMap<String, DownloadableFile.LocalFile> localFiles;
|
private final HashMap<String, DownloadableFile.LocalFile> localFiles;
|
||||||
|
|
||||||
public String getPathOf(String... rest) {
|
public String getPathOf(String... rest) {
|
||||||
File file = baseDir;
|
File file = libraryDir;
|
||||||
for (String part : rest) {
|
for (String part : rest) {
|
||||||
file = new File(file, part);
|
file = new File(file, part);
|
||||||
}
|
}
|
||||||
@ -49,9 +49,9 @@ public class LoaderSubResolver implements Function<String, String> {
|
|||||||
String libraryName = arg.substring(1, bound);
|
String libraryName = arg.substring(1, bound);
|
||||||
Library library = loader.findLibrary(libraryName);
|
Library library = loader.findLibrary(libraryName);
|
||||||
if (library != null) {
|
if (library != null) {
|
||||||
arg = getPathOf(manifest.getLibrariesLocation(), library.getPath(env));
|
arg = getPathOf(library.getPath(env));
|
||||||
} else {
|
} else {
|
||||||
arg = getPathOf(manifest.getLibrariesLocation(), Library.mavenNameToPath(libraryName));
|
arg = getPathOf(Library.mavenNameToPath(libraryName));
|
||||||
}
|
}
|
||||||
} else if (start == '&' && end == '&') {
|
} else if (start == '&' && end == '&') {
|
||||||
String localFileName = arg.substring(1, bound);
|
String localFileName = arg.substring(1, bound);
|
||||||
|
Loading…
Reference in New Issue
Block a user