Replace invalid characters when extracting ZIP

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
(cherry picked from commit 8056a2fa46)
This commit is contained in:
TheKodeToad 2024-04-05 23:12:31 +01:00 committed by github-actions[bot]
parent 58d32ea1af
commit 17d5d78a5b
3 changed files with 20 additions and 6 deletions

View file

@ -801,15 +801,24 @@ QString NormalizePath(QString path)
}
}
QString badFilenameChars = "\"\\/?<>:;*|!+\r\n";
static const QString BAD_PATH_CHARS = "\"?<>:;*|!+\r\n";
static const QString BAD_FILENAME_CHARS = BAD_PATH_CHARS + "\\/";
QString RemoveInvalidFilenameChars(QString string, QChar replaceWith)
{
for (int i = 0; i < string.length(); i++) {
if (badFilenameChars.contains(string[i])) {
for (int i = 0; i < string.length(); i++)
if (string.at(i).toLatin1() < ' ' || BAD_FILENAME_CHARS.contains(string.at(i)))
string[i] = replaceWith;
}
}
return string;
}
QString RemoveInvalidPathChars(QString string, QChar replaceWith)
{
for (int i = 0; i < string.length(); i++)
if (string.at(i) < ' ' || BAD_PATH_CHARS.contains(string.at(i)))
string[i] = replaceWith;
return string;
}