From 44de97a3724ba5eed3b2c2c4a69a6fd82ffa5fbe Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 24 Sep 2026 16:06:54 +0200 Subject: fix: an empty RRULE means does-not-repeat, not a custom rule --- src/repeatrule.cpp | 3 +++ tests/test_repeatrule.cpp | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/repeatrule.cpp b/src/repeatrule.cpp index cc11c91..b9b9539 100644 --- a/src/repeatrule.cpp +++ b/src/repeatrule.cpp @@ -79,6 +79,9 @@ RepeatRule RepeatRule::fromRRule(const QString &value, const QDate &start) return custom; }; + if (value.trimmed().isEmpty()) + return rule; + QMap parts; for (const QString &pair : value.split(QLatin1Char(';'), Qt::SkipEmptyParts)) { const int eq = pair.indexOf(QLatin1Char('=')); diff --git a/tests/test_repeatrule.cpp b/tests/test_repeatrule.cpp index 8962d14..aac6408 100644 --- a/tests/test_repeatrule.cpp +++ b/tests/test_repeatrule.cpp @@ -28,6 +28,7 @@ private slots: void roundTripsEveryRowOfTheTable_data(); void roundTripsEveryRowOfTheTable(); void fillsWhatAnRruleLeavesImplicit(); + void anEmptyRruleMeansDoesNotRepeat(); void recognisesACustomRule_data(); void recognisesACustomRule(); void keepsWkst(); @@ -76,6 +77,18 @@ void TestRepeatRule::fillsWhatAnRruleLeavesImplicit() QCOMPARE(monthly.monthDay, 18); } +void TestRepeatRule::anEmptyRruleMeansDoesNotRepeat() +{ + const QDate start(2026, 9, 18); + for (const QString &value : { QString(), QStringLiteral(""), QStringLiteral(" ") }) { + const RepeatRule rule = RepeatRule::fromRRule(value, start); + QCOMPARE(rule.freq, RepeatRule::Freq::None); + QVERIFY(!rule.custom); + QCOMPARE(rule.describe(), QStringLiteral("Does not repeat")); + QCOMPARE(rule.toRRule(), QString()); + } +} + void TestRepeatRule::recognisesACustomRule_data() { QTest::addColumn("rrule"); -- cgit v1.2.3