use a regex to remove all reserved characters from file names (#4804)
This commit is contained in:
parent
bd3100dcda
commit
cb52605928
1 changed files with 6 additions and 1 deletions
|
@ -266,9 +266,14 @@ CardInfoPtr CardInfo::newInstance(const QString &_name,
|
||||||
|
|
||||||
QString CardInfo::getCorrectedName() const
|
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;
|
QString result = name;
|
||||||
// Fire // Ice, Circle of Protection: Red, "Ach! Hans, Run!", Who/What/When/Where/Why, Question Elemental?
|
// 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)
|
void CardInfo::addToSet(const CardSetPtr &_set, const CardInfoPerSet _info)
|
||||||
|
|
Loading…
Reference in a new issue