mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
Fix invalid characters filename download on windows
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -240,11 +240,15 @@ bool ModrinthCreationTask::createInstance()
|
||||
auto root_modpack_url = QUrl::fromLocalFile(root_modpack_path);
|
||||
|
||||
for (auto file : m_files) {
|
||||
auto file_path = FS::PathCombine(root_modpack_path, file.path);
|
||||
auto fileName = file.path;
|
||||
#ifdef Q_OS_WIN
|
||||
fileName = FS::RemoveInvalidPathChars(fileName);
|
||||
#endif
|
||||
auto file_path = FS::PathCombine(root_modpack_path, fileName);
|
||||
if (!root_modpack_url.isParentOf(QUrl::fromLocalFile(file_path))) {
|
||||
// This means we somehow got out of the root folder, so abort here to prevent exploits
|
||||
setError(tr("One of the files has a path that leads to an arbitrary location (%1). This is a security risk and isn't allowed.")
|
||||
.arg(file.path));
|
||||
.arg(fileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user