mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-08-19 19:48:36 -04:00
pointer to referenceRegExp
This commit is contained in:
parent
40851409fb
commit
78acdf9095
3 changed files with 12 additions and 12 deletions
|
@ -690,20 +690,20 @@ QString Entry::resolvePlaceholder(const QString& str) const
|
||||||
// using format from http://keepass.info/help/base/fieldrefs.html at the time of writing,
|
// 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
|
// but supporting lookups of standard fields and references by UUID only
|
||||||
|
|
||||||
QRegExp tmpRegExp = m_attributes->referenceRegExp();
|
QRegExp* tmpRegExp = m_attributes->referenceRegExp();
|
||||||
if (tmpRegExp.indexIn(result) != -1) {
|
if (tmpRegExp->indexIn(result) != -1) {
|
||||||
// cap(0) contains the whole reference
|
// cap(0) contains the whole reference
|
||||||
// cap(1) contains which field is wanted
|
// cap(1) contains which field is wanted
|
||||||
// cap(2) contains the uuid of the referenced entry
|
// cap(2) contains the uuid of the referenced entry
|
||||||
Entry* tmpRefEntry = m_group->database()->resolveEntry(Uuid(QByteArray::fromHex(tmpRegExp.cap(2).toLatin1())));
|
Entry* tmpRefEntry = m_group->database()->resolveEntry(Uuid(QByteArray::fromHex(tmpRegExp->cap(2).toLatin1())));
|
||||||
if (tmpRefEntry) {
|
if (tmpRefEntry) {
|
||||||
// entry found, get the relevant field
|
// entry found, get the relevant field
|
||||||
QString tmpRefField = tmpRegExp.cap(1).toLower();
|
QString tmpRefField = tmpRegExp->cap(1).toLower();
|
||||||
if (tmpRefField == "t") result.replace(tmpRegExp.cap(0), tmpRefEntry->title(), Qt::CaseInsensitive);
|
if (tmpRefField == "t") result.replace(tmpRegExp->cap(0), tmpRefEntry->title(), Qt::CaseInsensitive);
|
||||||
else if (tmpRefField == "u") result.replace(tmpRegExp.cap(0), tmpRefEntry->username(), Qt::CaseInsensitive);
|
else if (tmpRefField == "u") result.replace(tmpRegExp->cap(0), tmpRefEntry->username(), Qt::CaseInsensitive);
|
||||||
else if (tmpRefField == "p") result.replace(tmpRegExp.cap(0), tmpRefEntry->password(), Qt::CaseInsensitive);
|
else if (tmpRefField == "p") result.replace(tmpRegExp->cap(0), tmpRefEntry->password(), Qt::CaseInsensitive);
|
||||||
else if (tmpRefField == "a") result.replace(tmpRegExp.cap(0), tmpRefEntry->url(), Qt::CaseInsensitive);
|
else if (tmpRefField == "a") result.replace(tmpRegExp->cap(0), tmpRefEntry->url(), Qt::CaseInsensitive);
|
||||||
else if (tmpRefField == "n") result.replace(tmpRegExp.cap(0), tmpRefEntry->notes(), Qt::CaseInsensitive);
|
else if (tmpRefField == "n") result.replace(tmpRegExp->cap(0), tmpRefEntry->notes(), Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,9 @@ bool EntryAttributes::isReference(const QString& key) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegExp EntryAttributes::referenceRegExp() const
|
QRegExp* EntryAttributes::referenceRegExp()
|
||||||
{
|
{
|
||||||
return m_referenceRegExp;
|
return &m_referenceRegExp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntryAttributes::set(const QString& key, const QString& value, bool protect)
|
void EntryAttributes::set(const QString& key, const QString& value, bool protect)
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
bool contains(const QString& key) const;
|
bool contains(const QString& key) const;
|
||||||
bool isProtected(const QString& key) const;
|
bool isProtected(const QString& key) const;
|
||||||
bool isReference(const QString& key) const;
|
bool isReference(const QString& key) const;
|
||||||
QRegExp referenceRegExp() const;
|
QRegExp* referenceRegExp();
|
||||||
void set(const QString& key, const QString& value, bool protect = false);
|
void set(const QString& key, const QString& value, bool protect = false);
|
||||||
void remove(const QString& key);
|
void remove(const QString& key);
|
||||||
void rename(const QString& oldKey, const QString& newKey);
|
void rename(const QString& oldKey, const QString& newKey);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue