diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 6f975af24..46b7ff1f3 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -997,19 +997,19 @@ void Entry::updateModifiedSinceBegin() QString Entry::resolveMultiplePlaceholdersRecursive(const QString& str, int maxDepth) const { + static QRegularExpression placeholderRegEx("(\\{[^\\}]+?\\})", QRegularExpression::CaseInsensitiveOption); + if (maxDepth <= 0) { qWarning("Maximum depth of replacement has been reached. Entry uuid: %s", uuid().toString().toLatin1().data()); return str; } QString result = str; - QRegExp placeholderRegEx("(\\{[^\\}]+\\})", Qt::CaseInsensitive, QRegExp::RegExp2); - placeholderRegEx.setMinimal(true); - int pos = 0; - while ((pos = placeholderRegEx.indexIn(str, pos)) != -1) { - const QString found = placeholderRegEx.cap(1); + auto matches = placeholderRegEx.globalMatch(str); + while (matches.hasNext()) { + auto match = matches.next(); + const auto found = match.captured(1); result.replace(found, resolvePlaceholderRecursive(found, maxDepth - 1)); - pos += placeholderRegEx.matchedLength(); } if (result != str) { diff --git a/src/gui/SortFilterHideProxyModel.cpp b/src/gui/SortFilterHideProxyModel.cpp index 20a1dfacc..73a856bbb 100644 --- a/src/gui/SortFilterHideProxyModel.cpp +++ b/src/gui/SortFilterHideProxyModel.cpp @@ -16,11 +16,11 @@ */ #include "SortFilterHideProxyModel.h" -#include SortFilterHideProxyModel::SortFilterHideProxyModel(QObject* parent) : QSortFilterProxyModel(parent) { + m_collator.setNumericMode(true); } Qt::DropActions SortFilterHideProxyModel::supportedDragActions() const @@ -38,7 +38,7 @@ void SortFilterHideProxyModel::hideColumn(int column, bool hide) bool SortFilterHideProxyModel::filterAcceptsColumn(int sourceColumn, const QModelIndex& sourceParent) const { - Q_UNUSED(sourceParent); + Q_UNUSED(sourceParent) return sourceColumn >= m_hiddenColumns.size() || !m_hiddenColumns.at(sourceColumn); } @@ -48,9 +48,7 @@ bool SortFilterHideProxyModel::lessThan(const QModelIndex& left, const QModelInd auto leftData = sourceModel()->data(left, sortRole()); auto rightData = sourceModel()->data(right, sortRole()); if (leftData.type() == QVariant::String) { - QCollator sorter; - sorter.setNumericMode(true); - return sorter.compare(leftData.toString(), rightData.toString()) < 0; + return m_collator.compare(leftData.toString(), rightData.toString()) < 0; } return QSortFilterProxyModel::lessThan(left, right); diff --git a/src/gui/SortFilterHideProxyModel.h b/src/gui/SortFilterHideProxyModel.h index 746ccbd96..742d8a3fb 100644 --- a/src/gui/SortFilterHideProxyModel.h +++ b/src/gui/SortFilterHideProxyModel.h @@ -19,6 +19,7 @@ #define KEEPASSX_SORTFILTERHIDEPROXYMODEL_H #include +#include #include class SortFilterHideProxyModel : public QSortFilterProxyModel @@ -36,6 +37,7 @@ protected: private: QBitArray m_hiddenColumns; + QCollator m_collator; }; #endif // KEEPASSX_SORTFILTERHIDEPROXYMODEL_H diff --git a/src/sshagent/KeeAgentSettings.cpp b/src/sshagent/KeeAgentSettings.cpp index c8e60e393..272fb7edf 100644 --- a/src/sshagent/KeeAgentSettings.cpp +++ b/src/sshagent/KeeAgentSettings.cpp @@ -355,7 +355,11 @@ bool KeeAgentSettings::inEntryAttachments(const EntryAttachments* attachments) */ bool KeeAgentSettings::fromEntry(const Entry* entry) { - return fromXml(entry->attachments()->value("KeeAgent.settings")); + const auto attachments = entry->attachments(); + if (attachments->hasKey("KeeAgent.settings")) { + return fromXml(attachments->value("KeeAgent.settings")); + } + return false; } /**