Commit 017cf99c authored by David Redondo's avatar David Redondo 🏎
Browse files

Escape filename before operating on it with regular expressions

If the filename contains characters that have special meaning they can cause
wrong behavior. This also caused the related test to fail in 1 of 10 times.
BUG: 418638
parent c013771e
......@@ -214,10 +214,11 @@ QString ExportManager::formatFilename(const QString &nameTemplate)
// if there are files in the directory...
if (fileNames.length() > 0) {
QString resultCopy = result;
QString resultCopy = QRegularExpression::escape(result);
QRegularExpression fileNumberRE;
const QString replacement = QStringLiteral("(\\d{").append(QString::number(paddedLength)).append(QLatin1String(",})"));
const QString fullNameMatch = QStringLiteral("^").append(resultCopy.replace(paddingMatch.captured(),replacement)).append(QStringLiteral("\\..*$"));
QString escapedMatch = QRegularExpression::escape(paddingMatch.captured());
const QString fullNameMatch = QStringLiteral("^").append(resultCopy.replace(escapedMatch,replacement)).append(QStringLiteral("\\..*$"));
// ... check the file names for string matching token with padding specified in result
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment