diff options
author | Eike Ziller <eike.ziller@qt.io> | 2019-06-17 17:51:55 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2019-06-18 09:45:06 +0000 |
commit | a2cfa434683552f63699a70e9de2295a12f41eaa (patch) | |
tree | 80ffaa86e251e5814838c64adef978946a5a2c6f | |
parent | 5bcc70b34deb1dd590cca0c115511f3c6fa9f763 (diff) | |
download | qt-creator-a2cfa434683552f63699a70e9de2295a12f41eaa.tar.gz |
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>
-rw-r--r-- | src/plugins/cpptools/cppfilesettingspage.cpp | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/plugins/cpptools/cppfilesettingspage.cpp b/src/plugins/cpptools/cppfilesettingspage.cpp index 187f5d5913..5ee5ef22cf 100644 --- a/src/plugins/cpptools/cppfilesettingspage.cpp +++ b/src/plugins/cpptools/cppfilesettingspage.cpp @@ -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. |