summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-24 16:06:54 +0200
committerDanilo M. <danix@danix.xyz>2026-09-24 16:06:54 +0200
commit44de97a3724ba5eed3b2c2c4a69a6fd82ffa5fbe (patch)
treeec965be6be95dc1868660fce4abfda64d502c6f2
parent6dcc0847e2089aeec1320d2a9227591c8767baf0 (diff)
downloadqtmaildir-44de97a3724ba5eed3b2c2c4a69a6fd82ffa5fbe.tar.gz
qtmaildir-44de97a3724ba5eed3b2c2c4a69a6fd82ffa5fbe.zip
fix: an empty RRULE means does-not-repeat, not a custom rule
-rw-r--r--src/repeatrule.cpp3
-rw-r--r--tests/test_repeatrule.cpp13
2 files changed, 16 insertions, 0 deletions
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<QString, QString> 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<QString>("rrule");