mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-25 08:51:21 -05:00
fix autotype custom attributes
This commit is contained in:
parent
d3a80513a7
commit
5f9f27604b
@ -659,6 +659,7 @@ bool AutoType::checkSyntax(const QString& string)
|
|||||||
QString delay = "DELAY=\\d+";
|
QString delay = "DELAY=\\d+";
|
||||||
QString beep = "BEEP\\s\\d+\\s\\d+";
|
QString beep = "BEEP\\s\\d+\\s\\d+";
|
||||||
QString vkey = "VKEY(?:-[EN]X)?\\s\\w+";
|
QString vkey = "VKEY(?:-[EN]X)?\\s\\w+";
|
||||||
|
QString customAttributes = "S:(?:[^\\{\\}])+";
|
||||||
|
|
||||||
// these chars aren't in parentheses
|
// these chars aren't in parentheses
|
||||||
QString shortcutKeys = "[\\^\\%~\\+@]";
|
QString shortcutKeys = "[\\^\\%~\\+@]";
|
||||||
@ -666,7 +667,7 @@ bool AutoType::checkSyntax(const QString& string)
|
|||||||
QString fixedStrings = "[^\\^\\%~\\+@\\{\\}]*";
|
QString fixedStrings = "[^\\^\\%~\\+@\\{\\}]*";
|
||||||
|
|
||||||
QRegularExpression autoTypeSyntax("^(?:" + shortcutKeys + "|" + fixedStrings + "|\\{(?:" + normalCommands + "|" + specialLiterals +
|
QRegularExpression autoTypeSyntax("^(?:" + shortcutKeys + "|" + fixedStrings + "|\\{(?:" + normalCommands + "|" + specialLiterals +
|
||||||
"|" + functionKeys + "|" + numpad + "|" + delay + "|" + beep + "|" + vkey + ")\\})*$",
|
"|" + functionKeys + "|" + numpad + "|" + delay + "|" + beep + "|" + vkey + ")\\}|\\{" + customAttributes + "\\})*$",
|
||||||
QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
QRegularExpressionMatch match = autoTypeSyntax.match(string);
|
QRegularExpressionMatch match = autoTypeSyntax.match(string);
|
||||||
return match.hasMatch();
|
return match.hasMatch();
|
||||||
|
@ -273,32 +273,41 @@ void TestAutoType::testGlobalAutoTypeRegExp()
|
|||||||
void TestAutoType::testAutoTypeSyntaxChecks()
|
void TestAutoType::testAutoTypeSyntaxChecks()
|
||||||
{
|
{
|
||||||
// Huge sequence
|
// Huge sequence
|
||||||
QCOMPARE(true, AutoType::checkSyntax("{word 23}{F1 23}{~ 23}{% 23}{^}{F12}{(}{) 23}{[}{[}{]}{Delay=23}{+}{SUBTRACT}~+%@fixedstring"));
|
QVERIFY(AutoType::checkSyntax("{word 23}{F1 23}{~ 23}{% 23}{^}{F12}{(}{) 23}{[}{[}{]}{Delay=23}{+}{SUBTRACT}~+%@fixedstring"));
|
||||||
|
|
||||||
QCOMPARE(true, AutoType::checkSyntax("{NUMPAD1 3}"));
|
QVERIFY(AutoType::checkSyntax("{NUMPAD1 3}"));
|
||||||
|
|
||||||
QCOMPARE(true, AutoType::checkSyntax("{BEEP 3 3}"));
|
QVERIFY(AutoType::checkSyntax("{S:SPECIALTOKEN}"));
|
||||||
QCOMPARE(false, AutoType::checkSyntax("{BEEP 3}"));
|
QVERIFY(AutoType::checkSyntax("{S:SPECIAL TOKEN}"));
|
||||||
|
QVERIFY(AutoType::checkSyntax("{S:SPECIAL_TOKEN}"));
|
||||||
|
QVERIFY(AutoType::checkSyntax("{S:SPECIAL-TOKEN}"));
|
||||||
|
QVERIFY(AutoType::checkSyntax("{S:SPECIAL:TOKEN}"));
|
||||||
|
QVERIFY(AutoType::checkSyntax("{S:SPECIAL_TOKEN}{ENTER}"));
|
||||||
|
QVERIFY(AutoType::checkSyntax("{S:FOO}{S:HELLO WORLD}"));
|
||||||
|
QVERIFY(!AutoType::checkSyntax("{S:SPECIAL_TOKEN{}}"));
|
||||||
|
|
||||||
QCOMPARE(true, AutoType::checkSyntax("{VKEY 0x01}"));
|
QVERIFY(AutoType::checkSyntax("{BEEP 3 3}"));
|
||||||
QCOMPARE(true, AutoType::checkSyntax("{VKEY VK_LBUTTON}"));
|
QVERIFY(!AutoType::checkSyntax("{BEEP 3}"));
|
||||||
QCOMPARE(true, AutoType::checkSyntax("{VKEY-EX 0x01}"));
|
|
||||||
|
QVERIFY(AutoType::checkSyntax("{VKEY 0x01}"));
|
||||||
|
QVERIFY(AutoType::checkSyntax("{VKEY VK_LBUTTON}"));
|
||||||
|
QVERIFY(AutoType::checkSyntax("{VKEY-EX 0x01}"));
|
||||||
// Bad sequence
|
// Bad sequence
|
||||||
QCOMPARE(false, AutoType::checkSyntax("{{{}}{}{}}{{}}"));
|
QVERIFY(!AutoType::checkSyntax("{{{}}{}{}}{{}}"));
|
||||||
// Good sequence
|
// Good sequence
|
||||||
QCOMPARE(true, AutoType::checkSyntax("{{}{}}{}}{{}"));
|
QVERIFY(AutoType::checkSyntax("{{}{}}{}}{{}"));
|
||||||
QCOMPARE(true, AutoType::checkSyntax("{]}{[}{[}{]}"));
|
QVERIFY(AutoType::checkSyntax("{]}{[}{[}{]}"));
|
||||||
QCOMPARE(true, AutoType::checkSyntax("{)}{(}{(}{)}"));
|
QVERIFY(AutoType::checkSyntax("{)}{(}{(}{)}"));
|
||||||
// High DelAY / low delay
|
// High DelAY / low delay
|
||||||
QCOMPARE(true, AutoType::checkHighDelay("{DelAY 50000}"));
|
QVERIFY(AutoType::checkHighDelay("{DelAY 50000}"));
|
||||||
QCOMPARE(false, AutoType::checkHighDelay("{delay 50}"));
|
QVERIFY(!AutoType::checkHighDelay("{delay 50}"));
|
||||||
// Slow typing
|
// Slow typing
|
||||||
QCOMPARE(true, AutoType::checkSlowKeypress("{DelAY=50000}"));
|
QVERIFY(AutoType::checkSlowKeypress("{DelAY=50000}"));
|
||||||
QCOMPARE(false, AutoType::checkSlowKeypress("{delay=50}"));
|
QVERIFY(!AutoType::checkSlowKeypress("{delay=50}"));
|
||||||
// Many repetition / few repetition / delay not repetition
|
// Many repetition / few repetition / delay not repetition
|
||||||
QCOMPARE(true, AutoType::checkHighRepetition("{LEFT 50000000}"));
|
QVERIFY(AutoType::checkHighRepetition("{LEFT 50000000}"));
|
||||||
QCOMPARE(false, AutoType::checkHighRepetition("{SPACE 10}{TAB 3}{RIGHT 50}"));
|
QVERIFY(!AutoType::checkHighRepetition("{SPACE 10}{TAB 3}{RIGHT 50}"));
|
||||||
QCOMPARE(false, AutoType::checkHighRepetition("{delay 5000000000}"));
|
QVERIFY(!AutoType::checkHighRepetition("{delay 5000000000}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestAutoType::testAutoTypeEffectiveSequences()
|
void TestAutoType::testAutoTypeEffectiveSequences()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user