diff --git a/src/autotype/AutoType.cpp b/src/autotype/AutoType.cpp index ac3be5b90..4ad83b086 100644 --- a/src/autotype/AutoType.cpp +++ b/src/autotype/AutoType.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "config-keepassx.h" @@ -328,8 +329,33 @@ bool AutoType::parseActions(const QString& sequence, const Entry* entry, QListget("AutoTypeDelay").toInt(); - for (const QChar& ch : sequence) { - if (inTmpl) { + if (!AutoType::checkSyntax(sequence)) { + QMessageBox messageBox; + messageBox.critical(0, "AutoType", tr("The Syntax of your AutoType statement is incorrect!")); + return false; + } + else if (AutoType::checkHighDelay(sequence)) { + QMessageBox::StandardButton reply; + reply = QMessageBox::question(0, + "AutoType", + tr("This AutoType command contains a very long delay. Do you really want to execute it?")); + + if (reply == QMessageBox::No) { + return false; + } + } + else if (AutoType::checkHighRepetition(sequence)) { + QMessageBox::StandardButton reply; + reply = QMessageBox::question(0, + "AutoType", + tr("This AutoType command contains arguments which are repeated very often. Do you really want to execute it?")); + + if (reply == QMessageBox::No) { + return false; + } + } + + for (const QChar &ch : sequence) { if (ch == '{') { qWarning("Syntax error in auto-type sequence."); return false; @@ -391,30 +417,6 @@ QList AutoType::createActionFromTemplate(const QString& tmpl, c if (num == 0) { return list; } - // some safety checks - else if (tmplName.compare("delay",Qt::CaseInsensitive)==0) { - if (num > 10000) { - QMessageBox::StandardButton reply; - reply = QMessageBox::question(0, - "AutoType", - tr("This AutoType command contains a very long delay. Do you really want to execute it?")); - - if (reply == QMessageBox::No) { - return list; - } - } - } - else if (num > 100) { - QMessageBox::StandardButton reply; - reply = QMessageBox::question(0, - "AutoType", - tr("This AutoType command contains arguments which are repeated very often. Do you really want to execute it?")); - - if (reply == QMessageBox::No) { - return list; - } - - } } if (tmplName.compare("tab", Qt::CaseInsensitive) == 0) { diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index f1bdc8145..171590513 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -767,18 +767,39 @@ void EditEntryWidget::updateEntryData(Entry* entry) const } else { if (!AutoType::checkSyntax(m_autoTypeUi->sequenceEdit->text())) { - //@TODO handle wrong syntax - std::cout << "wrong syntax\n"; + //handle wrong syntax + QMessageBox messageBox; + messageBox.critical(0, + "AutoType", + tr("The Syntax of your AutoType statement is incorrect! It won't be saved!")); + } else if (AutoType::checkHighDelay(m_autoTypeUi->sequenceEdit->text())) { - //@TODO handle too long delay - std::cout << "too long delay\n"; + //handle too long delay + QMessageBox::StandardButton reply; + reply = QMessageBox::question(0, + "AutoType", + tr("This AutoType command contains a very long delay. Do you really want to save it?")); + + if (reply == QMessageBox::Yes) { + entry->setDefaultAutoTypeSequence(m_autoTypeUi->sequenceEdit->text()); + } } else if (AutoType::checkHighRepetition(m_autoTypeUi->sequenceEdit->text())) { - //@TODO handle too much repetition - std::cout << "too much repetition\n"; + //handle too much repetition + QMessageBox::StandardButton reply; + reply = QMessageBox::question(0, + "AutoType", + tr("This AutoType command contains arguments which are repeated very often. Do you really want to save it?")); + + if (reply == QMessageBox::Yes) { + entry->setDefaultAutoTypeSequence(m_autoTypeUi->sequenceEdit->text()); + } } - entry->setDefaultAutoTypeSequence(m_autoTypeUi->sequenceEdit->text()); + else { + entry->setDefaultAutoTypeSequence(m_autoTypeUi->sequenceEdit->text()); + } + } entry->autoTypeAssociations()->copyDataFrom(m_autoTypeAssoc);