Commit fc41e5ff authored by Laurent Montel's avatar Laurent Montel 😁

Verify values

parent 2df985d3
......@@ -43,7 +43,8 @@ SieveEditorGraphicalModeWidgetTest::SieveEditorGraphicalModeWidgetTest(QObject *
QString readSieveFile(const QString &sieveFile)
{
QFile file(sieveFile);
file.open(QIODevice::ReadOnly);
bool result = file.open(QIODevice::ReadOnly);
Q_ASSERT(result);
Q_ASSERT(file.isOpen());
const QString data = QString::fromUtf8(file.readAll());
return data;
......
......@@ -94,26 +94,29 @@ void SieveForEveryPartWidget::generatedScript(QString &script, QStringList &requ
void SieveForEveryPartWidget::loadScript(QXmlStreamReader &element, QString &error)
{
element.readNextStartElement();
const QStringRef tagName = element.name();
if (tagName == QLatin1String("tag")) {
const QString tagValue = element.readElementText();
if (tagValue == QLatin1String("name")) {
mName->setText(AutoCreateScriptUtil::strValue(element));
if (element.readNextStartElement()) {
const QStringRef tagName = element.name();
if (tagName == QLatin1String("tag")) {
const QString tagValue = element.readElementText();
if (tagValue == QLatin1String("name")) {
mName->setText(AutoCreateScriptUtil::strValue(element));
} else {
error += i18n("Unknown tagValue \"%1\" during loading loop \"for\"", tagValue) + QLatin1Char('\n');
qCDebug(LIBKSIEVE_LOG) << " SieveForEveryPartWidget::loadScript unknown tagValue " << tagValue;
}
mForLoop->setChecked(true);
mName->setEnabled(true);
} else if (tagName == QLatin1String("block")) {
//Nothing
//It's when name is empty
} else if (tagName == QLatin1String("crlf")) {
//Nothing
element.skipCurrentElement();
} else {
error += i18n("Unknown tagValue \"%1\" during loading loop \"for\"", tagValue) + QLatin1Char('\n');
qCDebug(LIBKSIEVE_LOG) << " SieveForEveryPartWidget::loadScript unknown tagValue " << tagValue;
error += i18n("Unknown tag \"%1\" during loading loop \"for\"", tagName.toString()) + QLatin1Char('\n');
qCDebug(LIBKSIEVE_LOG) << " SieveForEveryPartWidget::loadScript unknown tagName " << tagName;
}
mForLoop->setChecked(true);
mName->setEnabled(true);
} else if (tagName == QLatin1String("block")) {
//Nothing
//It's when name is empty
} else if (tagName == QLatin1String("crlf")) {
//Nothing
element.skipCurrentElement();
} else {
error += i18n("Unknown tag \"%1\" during loading loop \"for\"", tagName.toString()) + QLatin1Char('\n');
qCDebug(LIBKSIEVE_LOG) << " SieveForEveryPartWidget::loadScript unknown tagName " << tagName;
qCDebug(LIBKSIEVE_LOG) << " SieveForEveryPartWidget::loadScript problem during loading";
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment