mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-03 08:41:42 +00:00
NOISSUE Improve path parsing for modrinth packs
This commit is contained in:
@@ -311,7 +311,13 @@ void InstanceImportTask::processModrinth() {
|
|||||||
auto jsonFiles = Json::requireIsArrayOf<QJsonObject>(obj, "files", "modrinth.index.json");
|
auto jsonFiles = Json::requireIsArrayOf<QJsonObject>(obj, "files", "modrinth.index.json");
|
||||||
for(auto & obj: jsonFiles) {
|
for(auto & obj: jsonFiles) {
|
||||||
Modrinth::File file;
|
Modrinth::File file;
|
||||||
file.path = Json::requireString(obj, "path");
|
auto dirtyPath = Json::requireString(obj, "path");
|
||||||
|
dirtyPath.replace('\\', '/');
|
||||||
|
auto simplifiedPath = QDir::cleanPath(dirtyPath);
|
||||||
|
QFileInfo fileInfo (simplifiedPath);
|
||||||
|
if(simplifiedPath.startsWith("../") || simplifiedPath.contains("/../") || fileInfo.isAbsolute()) {
|
||||||
|
throw JSONValidationError("Invalid path found in modpack files:\n\n" + simplifiedPath);
|
||||||
|
}
|
||||||
|
|
||||||
// env doesn't have to be present, in that case mod is required
|
// env doesn't have to be present, in that case mod is required
|
||||||
auto env = Json::ensureObject(obj, "env");
|
auto env = Json::ensureObject(obj, "env");
|
||||||
|
Reference in New Issue
Block a user