summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2016-09-22 16:09:31 +0200
committerKai Koehne <kai.koehne@qt.io>2016-10-11 14:37:32 +0000
commit30bbaae2dd02197997c8b2953b1f2d257935fc82 (patch)
tree5fd769177a560d768338eee6bc0ffabe791def29
parent09958bdb72e1ae4627c67485d94ae3b5e794a68c (diff)
qtattributionscanner: Ignore licenseId's with spaces
SPDX license expressions can contain more elaborate structs with AND and OR operators. Just ignore these for now in the .qdoc generation step. Change-Id: I9bcd432ebd6a188a1745432ddd3aa5b3bbd48b03 Reviewed-by: Topi Reiniƶ <topi.reinio@theqtcompany.com>
-rw-r--r--src/qtattributionsscanner/qdocgenerator.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/qtattributionsscanner/qdocgenerator.cpp b/src/qtattributionsscanner/qdocgenerator.cpp
index 92a2a9a48..429e101bb 100644
--- a/src/qtattributionsscanner/qdocgenerator.cpp
+++ b/src/qtattributionsscanner/qdocgenerator.cpp
@@ -34,6 +34,21 @@
namespace QDocGenerator {
+// See definition of idstring and licenseid in https://spdx.org/spdx-specification-21-web-version
+static bool isSpdxLicenseId(const QString &str) {
+ if (str.isEmpty())
+ return false;
+ for (auto iter(str.cbegin()); iter != str.cend(); ++iter) {
+ const QChar c = *iter;
+ if (!((c >= QLatin1Char('A') && c <= QLatin1Char('Z'))
+ || (c >= QLatin1Char('a') && c <= QLatin1Char('z'))
+ || (c >= QLatin1Char('0') && c <= QLatin1Char('9'))
+ || (c == QLatin1Char('-')) || (c == QLatin1Char('.'))))
+ return false;
+ }
+ return true;
+}
+
static void generate(QTextStream &out, const Package &package, const QDir &baseDir,
LogLevel logLevel)
{
@@ -60,7 +75,7 @@ static void generate(QTextStream &out, const Package &package, const QDir &baseD
if (!package.copyright.isEmpty())
out << "\n\\badcode\n" << package.copyright << "\n\\endcode\n\n";
- if (!package.licenseId.isEmpty() && package.licenseId != QLatin1String("NONE"))
+ if (isSpdxLicenseId(package.licenseId) && package.licenseId != QLatin1String("NONE"))
out << "\\l{https://spdx.org/licenses/" << package.licenseId << ".html}"
<< "{" << package.license << "}.\n\n";
else