forked from qt-creator/qt-creator
Fix expansion of %DATE% in license template
If the format contains '/', that must be escaped to avoid the expander to interpret that as regexp style replacement. Task-number: QTCREATORBUG-22440 Change-Id: Iaa6c0ae0aa74a055a30b3c0413e325c497f9310f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -169,6 +169,7 @@ static bool keyWordReplacement(const QString &keyWord,
|
||||
const QChar ypsilon = QLatin1Char('y');
|
||||
if (format.count(ypsilon) == 2)
|
||||
format.insert(format.indexOf(ypsilon), QString(2, ypsilon));
|
||||
format.replace('/', "\\/");
|
||||
}
|
||||
*value = QString::fromLatin1("%{CurrentDate:") + format + QLatin1Char('}');
|
||||
return true;
|
||||
@@ -193,7 +194,6 @@ static void parseLicenseTemplatePlaceholders(QString *t)
|
||||
{
|
||||
int pos = 0;
|
||||
const QChar placeHolder = QLatin1Char('%');
|
||||
bool isCompatibilityStyle = false;
|
||||
do {
|
||||
const int placeHolderPos = t->indexOf(placeHolder, pos);
|
||||
if (placeHolderPos == -1)
|
||||
@@ -208,7 +208,6 @@ static void parseLicenseTemplatePlaceholders(QString *t)
|
||||
const QString keyWord = t->mid(placeHolderPos, endPlaceHolderPos + 1 - placeHolderPos);
|
||||
QString replacement;
|
||||
if (keyWordReplacement(keyWord, &replacement)) {
|
||||
isCompatibilityStyle = true;
|
||||
t->replace(placeHolderPos, keyWord.size(), replacement);
|
||||
pos = placeHolderPos + replacement.size();
|
||||
} else {
|
||||
@@ -218,8 +217,6 @@ static void parseLicenseTemplatePlaceholders(QString *t)
|
||||
}
|
||||
} while (pos < t->size());
|
||||
|
||||
if (isCompatibilityStyle)
|
||||
t->replace(QLatin1Char('\\'), QLatin1String("\\\\"));
|
||||
}
|
||||
|
||||
// Convenience that returns the formatted license template.
|
||||
|
Reference in New Issue
Block a user