diff --git a/src/kauthaction.cpp b/src/kauthaction.cpp --- a/src/kauthaction.cpp +++ b/src/kauthaction.cpp @@ -20,7 +20,7 @@ #include "kauthaction.h" #include -#include +#include class QWidget; @@ -123,8 +123,8 @@ d->valid = BackendsManager::authBackend()->actionExists(name); } else { // Otherwise, check through a regexp - QRegExp exp(QLatin1String("[0-z]+(\\.[0-z]+)*")); - d->valid = exp.exactMatch(name); + const QRegularExpression re(QRegularExpression::anchoredPattern(QStringLiteral("[0-z]+(\\.[0-z]+)*"))); + d->valid = re.match(name).hasMatch(); } } diff --git a/src/policy-gen/policy-gen.cpp b/src/policy-gen/policy-gen.cpp --- a/src/policy-gen/policy-gen.cpp +++ b/src/policy-gen/policy-gen.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -71,13 +71,15 @@ QList parse(QSettings &ini) { QList actions; - QRegExp actionExp(QLatin1String("[0-9a-z]+(\\.[0-9a-z]+)*")); - QRegExp descriptionExp(QLatin1String("description(?:\\[(\\w+)\\])?")); - QRegExp nameExp(QLatin1String("name(?:\\[(\\w+)\\])?")); - QRegExp policyExp(QLatin1String("yes|no|auth_self|auth_admin")); + const QRegularExpression actionExp(QRegularExpression::anchoredPattern(QStringLiteral("[0-9a-z]+(\\.[0-9a-z]+)*"))); - descriptionExp.setCaseSensitivity(Qt::CaseInsensitive); - nameExp.setCaseSensitivity(Qt::CaseInsensitive); + const QRegularExpression descriptionExp(QRegularExpression::anchoredPattern(QStringLiteral("description(?:\\[(\\w+)\\])?")) + , QRegularExpression::CaseInsensitiveOption); + + const QRegularExpression nameExp(QRegularExpression::anchoredPattern(QStringLiteral("name(?:\\[(\\w+)\\])?")) + , QRegularExpression::CaseInsensitiveOption); + + const QRegularExpression policyExp(QRegularExpression::anchoredPattern(QStringLiteral("(?:yes|no|auth_self|auth_admin)"))); const auto listChilds = ini.childGroups(); for (const QString &name : listChilds) { @@ -87,7 +89,7 @@ continue; } - if (!actionExp.exactMatch(name)) { + if (!actionExp.match(name).hasMatch()) { qCritical("Wrong action syntax: %s\n", name.toLatin1().data()); exit(1); } @@ -97,17 +99,18 @@ const auto listChildKeys = ini.childKeys(); for (const QString &key : listChildKeys) { - if (descriptionExp.exactMatch(key)) { - QString lang = descriptionExp.capturedTexts().at(1); + QRegularExpressionMatch match; + if ((match = descriptionExp.match(key)).hasMatch()) { + QString lang = match.captured(); if (lang.isEmpty()) { lang = QString::fromLatin1("en"); } action.descriptions.insert(lang, ini.value(key).toString()); - } else if (nameExp.exactMatch(key)) { - QString lang = nameExp.capturedTexts().at(1); + } else if ((match = nameExp.match(key)).hasMatch()) { + QString lang = match.captured(); if (lang.isEmpty()) { lang = QString::fromLatin1("en"); @@ -117,15 +120,15 @@ } else if (key.toLower() == QLatin1String("policy")) { QString policy = ini.value(key).toString(); - if (!policyExp.exactMatch(policy)) { + if (!policyExp.match(policy).hasMatch()) { qCritical("Wrong policy: %s", policy.toLatin1().data()); exit(1); } action.policy = policy; } else if (key.toLower() == QLatin1String("policyinactive")) { QString policyInactive = ini.value(key).toString(); - if (!policyExp.exactMatch(policyInactive)) { + if (!policyExp.match(policyInactive).hasMatch()) { qCritical("Wrong policy: %s", policyInactive.toLatin1().data()); exit(1); }