diff --git a/src/api/KWallet/kwallet.cpp b/src/api/KWallet/kwallet.cpp --- a/src/api/KWallet/kwallet.cpp +++ b/src/api/KWallet/kwallet.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -176,13 +177,19 @@ attrs[KSS_ATTR_ENTRYFOLDER] = folder; KSecretsService::SearchCollectionItemsJob *searchItemsJob = secretsCollection->searchItems(attrs); if (searchItemsJob->exec()) { - const QRegExp re(key, Qt::CaseSensitive, QRegExp::Wildcard); + // HACK: QRegularExpression::wildcardToRegularExpression() mainly handles file pattern + // globbing (e.g. "*.txt") which means it doesn't allow "/" in the file name (which is + // technically correct); we have to subvert it because the keys in kwallet are in the + // form e.g. "foo.com/" which does have a "/" in it + const QString pattern = QRegularExpression::wildcardToRegularExpression(key).replace( + QLatin1String("[^/]"), QLatin1String(".")); + const QRegularExpression re(pattern); const auto list = searchItemsJob->items(); for (KSecretsService::SearchCollectionItemsJob::Item item : list) { KSecretsService::ReadItemPropertyJob *readLabelJob = item->label(); if (readLabelJob->exec()) { QString label = readLabelJob->propertyValue().toString(); - if (re.exactMatch(label)) { + if (re.match(label).hasMatch()) { if (verb(this, label, item.data())) { rc = 0; // one successful iteration already produced results, so success return } diff --git a/src/runtime/kwalletd/backend/kwalletbackend.cc b/src/runtime/kwalletd/backend/kwalletbackend.cc --- a/src/runtime/kwalletd/backend/kwalletbackend.cc +++ b/src/runtime/kwalletd/backend/kwalletbackend.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "blowfish.h" @@ -530,11 +531,14 @@ return rc; } - const QRegExp re(key, Qt::CaseSensitive, QRegExp::Wildcard); + // HACK: see Wallet::WalletPrivate::forEachItemThatMatches() + const QString pattern = QRegularExpression::wildcardToRegularExpression(key).replace( + QLatin1String("[^/]"), QLatin1String(".")); + const QRegularExpression re(pattern); const EntryMap &map = _entries[_folder]; for (EntryMap::ConstIterator i = map.begin(); i != map.end(); ++i) { - if (re.exactMatch(i.key())) { + if (re.match(i.key()).hasMatch()) { rc.append(i.value()); } }