check autotype syntax, high repetion, reformat code

TODO: specify what should happen when autotypesyntax incorrect
This commit is contained in:
Marco 2017-05-14 18:25:43 +02:00 committed by thez3ro
parent 45cb97ec85
commit 4fcedc2187
No known key found for this signature in database
GPG Key ID: F628F9E41DD7C073
2 changed files with 66 additions and 49 deletions

View File

@ -394,7 +394,8 @@ QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, c
else if (tmplName.compare("delay",Qt::CaseInsensitive)==0) {
if (num > 10000) {
QMessageBox::StandardButton reply;
reply = QMessageBox::question(0,"AutoType",
reply = QMessageBox::question(0,
"AutoType",
"This AutoType command contains a very long delay. Do you really want to execute it?");
if (reply == QMessageBox::No) {
@ -404,7 +405,8 @@ QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, c
}
else if (num > 100) {
QMessageBox::StandardButton reply;
reply = QMessageBox::question(0,"AutoType",
reply = QMessageBox::question(0,
"AutoType",
"This AutoType command contains arguments which are repeated very often. Do you really want to execute it?");
if (reply == QMessageBox::No) {
@ -644,7 +646,8 @@ QString AutoType::autoTypeSequence(const Entry* entry, const QString& windowTitl
group = group->parentGroup();
} while (group && (!enableSet || sequence.isEmpty()));
if (sequence.isEmpty() && (!entry->resolvePlaceholder(entry->username()).isEmpty() || !entry->resolvePlaceholder(entry->password()).isEmpty())) {
if (sequence.isEmpty() && (!entry->resolvePlaceholder(entry->username()).isEmpty()
|| !entry->resolvePlaceholder(entry->password()).isEmpty())) {
if (entry->resolvePlaceholder(entry->username()).isEmpty()) {
sequence = "{PASSWORD}{ENTER}";
}

View File

@ -764,6 +764,20 @@ void EditEntryWidget::updateEntryData(Entry* entry) const
entry->setDefaultAutoTypeSequence(QString());
}
else {
QRegExp autoTypeSyntax("(\\{[A-Z]*(\\s[0-9]*){0,1}\\})*");
autoTypeSyntax.setCaseSensitivity(Qt::CaseInsensitive);
autoTypeSyntax.setPatternSyntax(QRegExp::RegExp);
QRegExp highRepetition(".*[0-9]{3,}.*"); //the 3 means 3 digitnumbers are too much
highRepetition.setPatternSyntax(QRegExp::RegExp);
if (!autoTypeSyntax.exactMatch(m_autoTypeUi->sequenceEdit->text())) {
//@TODO handle wrong syntax
}
if (!highRepetition.exactMatch(m_autoTypeUi->sequenceEdit->text())) {
//@TODO handle too much repetition
}
entry->setDefaultAutoTypeSequence(m_autoTypeUi->sequenceEdit->text());
}