Fix display issues of entry attributes in preview pane

* Fix #5755 - HTML escape attributes prior to preview
* Place attribute preview into a table and convert line breaks
This commit is contained in:
Michel D'HOOGE 2020-12-19 10:49:53 -05:00 committed by Jonathan White
parent 2ee4168956
commit e8dfa9cfa1

View File

@ -286,14 +286,18 @@ void EntryPreviewWidget::updateEntryAdvancedTab()
setTabEnabled(m_ui->entryTabWidget, m_ui->entryAdvancedTab, hasAttributes || hasAttachments); setTabEnabled(m_ui->entryTabWidget, m_ui->entryAdvancedTab, hasAttributes || hasAttachments);
if (hasAttributes) { if (hasAttributes) {
QString attributesText; QString attributesText("<table>");
for (const QString& key : customAttributes) { for (const QString& key : customAttributes) {
QString value = m_currentEntry->attributes()->value(key); QString value;
if (m_currentEntry->attributes()->isProtected(key)) { if (m_currentEntry->attributes()->isProtected(key)) {
value = "<i>" + tr("[PROTECTED]") + "</i>"; value = "<i>" + tr("[PROTECTED]") + "</i>";
} else {
value = m_currentEntry->attributes()->value(key).toHtmlEscaped();
value.replace('\n', QLatin1String("<br/>"));
} }
attributesText.append(tr("<b>%1</b>: %2", "attributes line").arg(key, value).append("<br/>")); attributesText.append(tr("<tr><td><b>%1</b>:</td><td>%2</td></tr>", "attributes line").arg(key, value));
} }
attributesText.append("</table>");
m_ui->entryAttributesEdit->setText(attributesText); m_ui->entryAttributesEdit->setText(attributesText);
} }