Replace invalid characters when extracting ZIP

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2024-04-05 23:12:31 +01:00
parent 44ea8cd885
commit 8056a2fa46
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;
}