From ae51450ea64970dcdc544185d68e1e73fb390caa Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Tue, 1 Jul 2014 20:33:41 +0200 Subject: Fix reading of XDG style semicolon separated lists with escaped ';' Previously the warning "Invalid escape sequence "\;"." would appear and "\;" was replaced with just the backslash as is done for all unrecognized escape sequences. Keep both characters so that readXdgListEntry() works with values containing semicolons REVIEW: 119074 --- autotests/kconfigtest.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'autotests/kconfigtest.cpp') diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 5f2c7989..7cb3f903 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1672,6 +1672,33 @@ void KConfigTest::testNewlines() } +void KConfigTest::testXdgListEntry() +{ + QTemporaryFile file; + QVERIFY(file.open()); + QTextStream out(&file); + out << "[General]" << endl + << "Key1=" << endl // empty list + // emtpty entries + << "Key2=;" << endl + << "Key3=;;" << endl + << "Key4=;;;" << endl + << "Key5=\\;" << endl + << "Key6=1;2\\;3;;" << endl; + out.flush(); + file.close(); + KConfig anonConfig(file.fileName(), KConfig::SimpleConfig); + KConfigGroup grp = anonConfig.group("General"); + QStringList invalidList; // use this as a default when an empty list is expected + invalidList << "Error! Default value read!"; + QCOMPARE(grp.readXdgListEntry("Key1", invalidList), QStringList()); + QCOMPARE(grp.readXdgListEntry("Key2", invalidList), QStringList() << QString()); + QCOMPARE(grp.readXdgListEntry("Key3", invalidList), QStringList() << QString() << QString()); + QCOMPARE(grp.readXdgListEntry("Key4", invalidList), QStringList()<< QString() << QString() << QString()); + QCOMPARE(grp.readXdgListEntry("Key5", invalidList), QStringList() << ";"); + QCOMPARE(grp.readXdgListEntry("Key6", invalidList), QStringList() << "1" << "2;3" << QString()); +} + #include #include -- cgit v1.2.1