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
Jonathan White
parent
fedcbf60c5
commit
44daca921a
@@ -449,6 +449,11 @@ namespace Tools
|
|||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString escapeAccelerators(QString string)
|
||||||
|
{
|
||||||
|
return string.replace("&", "&&");
|
||||||
|
}
|
||||||
|
|
||||||
QVariantMap qo2qvm(const QObject* object, const QStringList& ignoredProperties)
|
QVariantMap qo2qvm(const QObject* object, const QStringList& ignoredProperties)
|
||||||
{
|
{
|
||||||
QVariantMap result;
|
QVariantMap result;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace Tools
|
|||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment());
|
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment());
|
||||||
QString cleanFilename(QString filename);
|
QString cleanFilename(QString filename);
|
||||||
QString cleanUsername();
|
QString cleanUsername();
|
||||||
|
QString escapeAccelerators(QString string);
|
||||||
|
|
||||||
template <class T> QSet<T> asSet(const QList<T>& a)
|
template <class T> QSet<T> asSet(const QList<T>& a)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -674,7 +674,7 @@ void DatabaseTabWidget::updateTabName(int index)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
index = indexOf(dbWidget);
|
index = indexOf(dbWidget);
|
||||||
setTabText(index, tabName(index));
|
setTabText(index, Tools::escapeAccelerators(tabName(index)));
|
||||||
setTabToolTip(index, dbWidget->displayFilePath());
|
setTabToolTip(index, dbWidget->displayFilePath());
|
||||||
auto iconIndex = dbWidget->database()->publicIcon();
|
auto iconIndex = dbWidget->database()->publicIcon();
|
||||||
if (iconIndex >= 0 && iconIndex < databaseIcons()->count()) {
|
if (iconIndex >= 0 && iconIndex < databaseIcons()->count()) {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include "autotype/AutoType.h"
|
#include "autotype/AutoType.h"
|
||||||
#include "core/InactivityTimer.h"
|
#include "core/InactivityTimer.h"
|
||||||
#include "core/Resources.h"
|
#include "core/Resources.h"
|
||||||
|
#include "core/Tools.h"
|
||||||
#include "gui/AboutDialog.h"
|
#include "gui/AboutDialog.h"
|
||||||
#include "gui/ActionCollection.h"
|
#include "gui/ActionCollection.h"
|
||||||
#include "gui/Icons.h"
|
#include "gui/Icons.h"
|
||||||
@@ -789,7 +790,7 @@ void MainWindow::updateLastDatabasesMenu()
|
|||||||
|
|
||||||
const QStringList lastDatabases = config()->get(Config::LastDatabases).toStringList();
|
const QStringList lastDatabases = config()->get(Config::LastDatabases).toStringList();
|
||||||
for (const QString& database : lastDatabases) {
|
for (const QString& database : lastDatabases) {
|
||||||
QAction* action = m_ui->menuRecentDatabases->addAction(database);
|
QAction* action = m_ui->menuRecentDatabases->addAction(Tools::escapeAccelerators(database));
|
||||||
action->setData(database);
|
action->setData(database);
|
||||||
m_lastDatabasesActions->addAction(action);
|
m_lastDatabasesActions->addAction(action);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -451,3 +451,14 @@ void TestTools::testCleanUsername_data()
|
|||||||
QTest::newRow("Trailing dots and spaces") << "username... " << "username";
|
QTest::newRow("Trailing dots and spaces") << "username... " << "username";
|
||||||
QTest::newRow("Combination of issues") << R"( user<>:"/\|?*name... )" << "user_________name";
|
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 testIsTextMimeType();
|
||||||
void testCleanUsername();
|
void testCleanUsername();
|
||||||
void testCleanUsername_data();
|
void testCleanUsername_data();
|
||||||
|
void testEscapeAccelerators();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KEEPASSX_TESTTOOLS_H
|
#endif // KEEPASSX_TESTTOOLS_H
|
||||||
|
|||||||
Reference in New Issue
Block a user