mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-27 18:10:31 -05:00
Sanitize username to prevent single-instance detection failure (#12559)
--------- Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
parent
f927c4c41a
commit
d9ccf767d0
5 changed files with 61 additions and 11 deletions
|
|
@ -428,3 +428,26 @@ void TestTools::testIsTextMimeType()
|
|||
QVERIFY(!Tools::isTextMimeType(noText));
|
||||
}
|
||||
}
|
||||
|
||||
// Test sanitization logic for Tools::cleanUsername
|
||||
void TestTools::testCleanUsername()
|
||||
{
|
||||
// Test vars
|
||||
QFETCH(QString, input);
|
||||
QFETCH(QString, expected);
|
||||
|
||||
qputenv("USER", input.toUtf8());
|
||||
qputenv("USERNAME", input.toUtf8());
|
||||
QCOMPARE(Tools::cleanUsername(), expected);
|
||||
}
|
||||
|
||||
void TestTools::testCleanUsername_data()
|
||||
{
|
||||
QTest::addColumn<QString>("input");
|
||||
QTest::addColumn<QString>("expected");
|
||||
|
||||
QTest::newRow("Leading and trailing spaces") << " user " << "user";
|
||||
QTest::newRow("Special characters") << R"(user<>:"/\|?*name)" << "user_________name";
|
||||
QTest::newRow("Trailing dots and spaces") << "username... " << "username";
|
||||
QTest::newRow("Combination of issues") << R"( user<>:"/\|?*name... )" << "user_________name";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue