diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 208a1dec..235dd3a7 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -690,7 +690,7 @@ QString Entry::resolvePlaceholder(const QString& str) const // using format from http://keepass.info/help/base/fieldrefs.html at the time of writing, // but supporting lookups of standard fields and references by UUID only - QRegExp tmpRegExp("\\{REF:([TUPAN])@I:([^}]+)\\}", Qt::CaseInsensitive, QRegExp::RegExp2); + QRegExp tmpRegExp = m_attributes->referenceRegExp(); if (tmpRegExp.indexIn(result) != -1) { // cap(0) contains the whole reference // cap(1) contains which field is wanted diff --git a/src/core/EntryAttributes.cpp b/src/core/EntryAttributes.cpp index 6f3c4fd6..94e5f96b 100644 --- a/src/core/EntryAttributes.cpp +++ b/src/core/EntryAttributes.cpp @@ -28,6 +28,7 @@ const QString EntryAttributes::RememberCmdExecAttr = "_EXEC_CMD"; EntryAttributes::EntryAttributes(QObject* parent) : QObject(parent) + , m_referenceRegExp("\\{REF:([TUPAN])@I:([^}]+)\\}", Qt::CaseInsensitive, QRegExp::RegExp2) { clear(); } @@ -77,13 +78,17 @@ bool EntryAttributes::isReference(const QString& key) const } QString data = value(key); - QRegExp referenceRegExp("\\{REF:([TUPAN])@I:([^}]+)\\}", Qt::CaseInsensitive, QRegExp::RegExp2); - if (referenceRegExp.indexIn(data) != -1) { + if (m_referenceRegExp.indexIn(data) != -1) { return true; } return false; } +QRegExp EntryAttributes::referenceRegExp() const +{ + return m_referenceRegExp; +} + void EntryAttributes::set(const QString& key, const QString& value, bool protect) { bool emitModified = false; diff --git a/src/core/EntryAttributes.h b/src/core/EntryAttributes.h index be33ab16..42abed1e 100644 --- a/src/core/EntryAttributes.h +++ b/src/core/EntryAttributes.h @@ -36,6 +36,7 @@ public: bool contains(const QString& key) const; bool isProtected(const QString& key) const; bool isReference(const QString& key) const; + QRegExp referenceRegExp() const; void set(const QString& key, const QString& value, bool protect = false); void remove(const QString& key); void rename(const QString& oldKey, const QString& newKey); @@ -72,6 +73,7 @@ Q_SIGNALS: private: QMap m_attributes; QSet m_protectedAttributes; + QRegExp m_referenceRegExp; }; #endif // KEEPASSX_ENTRYATTRIBUTES_H