mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Escape accelerators
(fixes issue #12037) Signed-off-by: Sven Strickroth <email@cs-ware.de>
This commit is contained in:
committed by
Janek Bevendorff
parent
61413e7a61
commit
b9bd1c3c00
@@ -449,6 +449,11 @@ namespace Tools
|
||||
return userName;
|
||||
}
|
||||
|
||||
QString escapeAccelerators(QString string)
|
||||
{
|
||||
return string.replace("&", "&&");
|
||||
}
|
||||
|
||||
QVariantMap qo2qvm(const QObject* object, const QStringList& ignoredProperties)
|
||||
{
|
||||
QVariantMap result;
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace Tools
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment());
|
||||
QString cleanFilename(QString filename);
|
||||
QString cleanUsername();
|
||||
QString escapeAccelerators(QString string);
|
||||
|
||||
template <class T> QSet<T> asSet(const QList<T>& a)
|
||||
{
|
||||
|
||||
@@ -655,7 +655,7 @@ void DatabaseTabWidget::updateTabName(int index)
|
||||
return;
|
||||
}
|
||||
index = indexOf(dbWidget);
|
||||
setTabText(index, tabName(index));
|
||||
setTabText(index, Tools::escapeAccelerators(tabName(index)));
|
||||
setTabToolTip(index, dbWidget->displayFilePath());
|
||||
auto iconIndex = dbWidget->database()->publicIcon();
|
||||
if (iconIndex >= 0 && iconIndex < databaseIcons()->count()) {
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "autotype/AutoType.h"
|
||||
#include "core/InactivityTimer.h"
|
||||
#include "core/Resources.h"
|
||||
#include "core/Tools.h"
|
||||
#include "gui/AboutDialog.h"
|
||||
#include "gui/Icons.h"
|
||||
#include "gui/MessageBox.h"
|
||||
@@ -814,7 +815,7 @@ void MainWindow::updateLastDatabasesMenu()
|
||||
|
||||
const QStringList lastDatabases = config()->get(Config::LastDatabases).toStringList();
|
||||
for (const QString& database : lastDatabases) {
|
||||
QAction* action = m_ui->menuRecentDatabases->addAction(database);
|
||||
QAction* action = m_ui->menuRecentDatabases->addAction(Tools::escapeAccelerators(database));
|
||||
action->setData(database);
|
||||
m_lastDatabasesActions->addAction(action);
|
||||
}
|
||||
|
||||
@@ -451,3 +451,14 @@ void TestTools::testCleanUsername_data()
|
||||
QTest::newRow("Trailing dots and spaces") << "username... " << "username";
|
||||
QTest::newRow("Combination of issues") << R"( user<>:"/\|?*name... )" << "user_________name";
|
||||
}
|
||||
|
||||
void TestTools::testEscapeAccelerators()
|
||||
{
|
||||
QCOMPARE(Tools::escapeAccelerators(""), "");
|
||||
QCOMPARE(Tools::escapeAccelerators("NoAccelerator"), "NoAccelerator");
|
||||
QCOMPARE(Tools::escapeAccelerators("&Accelerator"), "&&Accelerator");
|
||||
QCOMPARE(Tools::escapeAccelerators("Accelerator&"), "Accelerator&&");
|
||||
QCOMPARE(Tools::escapeAccelerators("Accel&erator&"), "Accel&&erator&&");
|
||||
QCOMPARE(Tools::escapeAccelerators("Accel&&erator"), "Accel&&&&erator");
|
||||
QCOMPARE(Tools::escapeAccelerators("Some & text"), "Some && text");
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ private slots:
|
||||
void testIsTextMimeType();
|
||||
void testCleanUsername();
|
||||
void testCleanUsername_data();
|
||||
void testEscapeAccelerators();
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_TESTTOOLS_H
|
||||
|
||||
Reference in New Issue
Block a user