Mask passwords in URL column in Entry View

This commit is contained in:
Jonathan White 2017-09-29 14:10:54 -04:00 committed by Jonathan White
parent cb0b948603
commit 59786d7bd7
3 changed files with 11 additions and 2 deletions

View File

@ -727,6 +727,13 @@ const Database* Entry::database() const
} }
} }
QString Entry::maskPasswordPlaceholders(const QString &str) const
{
QString result = str;
result.replace(QRegExp("(\\{PASSWORD\\})", Qt::CaseInsensitive, QRegExp::RegExp2), "******");
return result;
}
QString Entry::resolveMultiplePlaceholders(const QString& str) const QString Entry::resolveMultiplePlaceholders(const QString& str) const
{ {
QString result = str; QString result = str;
@ -818,4 +825,4 @@ QString Entry::resolveUrl(const QString& url) const
Q_UNUSED(url); Q_UNUSED(url);
#endif #endif
return QString(""); return QString("");
} }

View File

@ -142,6 +142,7 @@ public:
*/ */
Entry* clone(CloneFlags flags) const; Entry* clone(CloneFlags flags) const;
void copyDataFrom(const Entry* other); void copyDataFrom(const Entry* other);
QString maskPasswordPlaceholders(const QString& str) const;
QString resolveMultiplePlaceholders(const QString& str) const; QString resolveMultiplePlaceholders(const QString& str) const;
QString resolvePlaceholder(const QString& str) const; QString resolvePlaceholder(const QString& str) const;
QString resolveUrl(const QString& url) const; QString resolveUrl(const QString& url) const;

View File

@ -151,7 +151,8 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
} }
return result; return result;
case Url: case Url:
result = entry->resolveMultiplePlaceholders(entry->url()); result = entry->maskPasswordPlaceholders(entry->url());
result = entry->resolveMultiplePlaceholders(result);
if (attr->isReference(EntryAttributes::URLKey)) { if (attr->isReference(EntryAttributes::URLKey)) {
result.prepend(tr("Ref: ","Reference abbreviation")); result.prepend(tr("Ref: ","Reference abbreviation"));
} }