From eaaafb91919029b8824d972a7e45d47eaafca025 Mon Sep 17 00:00:00 2001 From: Barinade Date: Sun, 8 Jan 2023 22:09:03 -0600 Subject: [PATCH] fix partial pack downloading by forcing paths to be ascii please someone find a better solution. this sucks --- src/Etterna/Singletons/DownloadManager.cpp | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Etterna/Singletons/DownloadManager.cpp b/src/Etterna/Singletons/DownloadManager.cpp index 198c4dbdfa..fb74ce06d4 100644 --- a/src/Etterna/Singletons/DownloadManager.cpp +++ b/src/Etterna/Singletons/DownloadManager.cpp @@ -122,10 +122,10 @@ DownloadManager::InstallSmzip(const string& sZipFile) string doot = TEMP_ZIP_MOUNT_POINT; if (v_packs.size() > 1) { - doot += sZipFile.substr(sZipFile.find_last_of('/') + - 1); // attempt to whitelist pack name, this - // should be pretty simple/safe solution for - // a lot of pad packs -mina + // attempt to whitelist pack name, this + // should be pretty simple/safe solution for + // a lot of pad packs -mina + doot += sZipFile.substr(sZipFile.find_last_of('/') + 1); doot = doot.substr(0, doot.length() - 4) + "/"; } @@ -159,6 +159,25 @@ DownloadManager::InstallSmzip(const string& sZipFile) sDestFile = tail(std::string(sDestFile.c_str()), sDestFile.length() - TEMP_ZIP_MOUNT_POINT.length()); + // forcibly convert the path string to ASCII/ANSI/whatever + // basically remove everything that isnt normal + // and dont care about locales + std::vector bytes(sDestFile.begin(), sDestFile.end()); + bytes.push_back('\0'); + std::string res{}; + for (auto i = 0; i < bytes.size(); i++) { + auto c = bytes.at(i); + if (c > 122) { + res.append(std::to_string(c - 122)); + } else { + res.push_back(c); + } + } + if (res.length() > 256) { + res = res.substr(0, 255); + } + sDestFile = res; + std::string sDir, sThrowAway; splitpath(sDestFile, sDir, sThrowAway, sThrowAway);