use a regex to remove all reserved characters from file names (#4804)

This commit is contained in:
ebbit1q 2023-08-06 23:46:22 +02:00 committed by GitHub
parent bd3100dcda
commit cb52605928
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -266,9 +266,14 @@ CardInfoPtr CardInfo::newInstance(const QString &_name,
QString CardInfo::getCorrectedName() const
{
// remove all the characters reserved in windows file paths,
// other oses only disallow a subset of these so it covers all
static const QRegularExpression rmrx(R"(( // |[*<>:"\\?\x00-\x08\x10-\x1f]))");
static const QRegularExpression spacerx(R"([/\x09-\x0f])");
static const QString space(' ');
QString result = name;
// Fire // Ice, Circle of Protection: Red, "Ach! Hans, Run!", Who/What/When/Where/Why, Question Elemental?
return result.remove(" // ").remove(':').remove('"').remove('?').replace('/', ' ');
return result.remove(rmrx).replace(spacerx, space);
}
void CardInfo::addToSet(const CardSetPtr &_set, const CardInfoPerSet _info)