diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 25ef6b50e..800de0b06 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -287,8 +287,7 @@ QString Entry::webUrl() const QString Entry::displayUrl() const { QString url = maskPasswordPlaceholders(m_attributes->value(EntryAttributes::URLKey)); - url = resolveMultiplePlaceholders(url); - return resolveUrl(url); + return resolveMultiplePlaceholders(url); } QString Entry::username() const diff --git a/src/core/Uuid.cpp b/src/core/Uuid.cpp index 1b531159f..cb32bfdc7 100644 --- a/src/core/Uuid.cpp +++ b/src/core/Uuid.cpp @@ -88,13 +88,19 @@ bool Uuid::operator!=(const Uuid& other) const Uuid Uuid::fromBase64(const QString& str) { QByteArray data = QByteArray::fromBase64(str.toLatin1()); - return Uuid(data); + if (data.size() == Uuid::Length) { + return Uuid(data); + } + return {}; } Uuid Uuid::fromHex(const QString& str) { QByteArray data = QByteArray::fromHex(str.toLatin1()); - return Uuid(data); + if (data.size() == Uuid::Length) { + return Uuid(data); + } + return {}; } uint qHash(const Uuid& key) diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index 0573a0189..69c0e7c81 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -633,25 +633,22 @@ void DatabaseWidget::openUrl() void DatabaseWidget::openUrlForEntry(Entry* entry) { - QString urlString = entry->resolveMultiplePlaceholders(entry->url()); - if (urlString.isEmpty()) { - return; - } - - if (urlString.startsWith("cmd://")) { + QString cmdString = entry->resolveMultiplePlaceholders(entry->url()); + if (cmdString.startsWith("cmd://")) { // check if decision to execute command was stored if (entry->attributes()->hasKey(EntryAttributes::RememberCmdExecAttr)) { if (entry->attributes()->value(EntryAttributes::RememberCmdExecAttr) == "1") { - QProcess::startDetached(urlString.mid(6)); + QProcess::startDetached(cmdString.mid(6)); } return; } // otherwise ask user - if (urlString.length() > 6) { - QString cmdTruncated = urlString.mid(6); - if (cmdTruncated.length() > 400) + if (cmdString.length() > 6) { + QString cmdTruncated = cmdString.mid(6); + if (cmdTruncated.length() > 400) { cmdTruncated = cmdTruncated.left(400) + " […]"; + } QMessageBox msgbox(QMessageBox::Icon::Question, tr("Execute command?"), tr("Do you really want to execute the following command?

%1
") @@ -672,7 +669,7 @@ void DatabaseWidget::openUrlForEntry(Entry* entry) int result = msgbox.exec(); if (result == QMessageBox::Yes) { - QProcess::startDetached(urlString.mid(6)); + QProcess::startDetached(cmdString.mid(6)); } if (remember) { @@ -680,10 +677,11 @@ void DatabaseWidget::openUrlForEntry(Entry* entry) result == QMessageBox::Yes ? "1" : "0"); } } - } - else { - QUrl url = QUrl::fromUserInput(urlString); - QDesktopServices::openUrl(url); + } else { + QString urlString = entry->webUrl(); + if (!urlString.isEmpty()) { + QDesktopServices::openUrl(urlString); + } } } diff --git a/src/gui/DetailsWidget.cpp b/src/gui/DetailsWidget.cpp index dcabf964f..93b4b9f6e 100644 --- a/src/gui/DetailsWidget.cpp +++ b/src/gui/DetailsWidget.cpp @@ -174,17 +174,15 @@ void DetailsWidget::updateEntryGeneralTab() m_ui->entryPasswordLabel->setToolTip({}); } + m_ui->entryUrlLabel->setRawText(m_currentEntry->displayUrl()); const QString url = m_currentEntry->webUrl(); if (!url.isEmpty()) { // URL is well formed and can be opened in a browser - // create a new display url that masks password placeholders - // the actual link will use the password - m_ui->entryUrlLabel->setRawText(m_currentEntry->displayUrl()); m_ui->entryUrlLabel->setUrl(url); + m_ui->entryUrlLabel->setCursor(Qt::PointingHandCursor); } else { - // Fallback to the raw url string - m_ui->entryUrlLabel->setRawText(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->url())); m_ui->entryUrlLabel->setUrl({}); + m_ui->entryUrlLabel->setCursor(Qt::ArrowCursor); } const TimeInfo entryTime = m_currentEntry->timeInfo(); diff --git a/src/gui/DetailsWidget.ui b/src/gui/DetailsWidget.ui index 53787d713..38906150e 100644 --- a/src/gui/DetailsWidget.ui +++ b/src/gui/DetailsWidget.ui @@ -203,6 +203,9 @@ + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse +