mirror of https://github.com/qt/qtbase.git
QSettings: Add parsing errors for '\' and '/'
When sections contains '\' or '/' we should return a parse error as the documentation states we should not use them in sections. Fixes: QTBUG-138648 Change-Id: I273f22104f7e7e7d33ad45b1218d7816d38ff0c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
cbaaa5a9e1
commit
a6a1571018
|
@ -1425,6 +1425,13 @@ void QConfFileSettingsPrivate::syncConfFile(QConfFile *confFile)
|
|||
}
|
||||
}
|
||||
|
||||
for (const auto §ion : confFile->unparsedIniSections.keys()) {
|
||||
if (section.count(u'/') > 1) {
|
||||
setStatus(QSettings::FormatError);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
setStatus(QSettings::FormatError);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ set(qsettings_resource_files
|
|||
"float.ini"
|
||||
"qt5settings.ini"
|
||||
"utf8settings.ini"
|
||||
"incorrectsection.ini"
|
||||
)
|
||||
|
||||
qt_internal_add_test(tst_qsettings
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
[MAIN]
|
||||
TestInMain=MyTestString
|
||||
Test2InMain=MyTestString2
|
||||
|
||||
[Cars]
|
||||
Type=Renault
|
||||
Kmh=250
|
||||
|
||||
[Cars/German]
|
||||
Type=VW
|
||||
Kmh=180
|
||||
|
|
@ -208,6 +208,8 @@ private slots:
|
|||
void testReadKeys_data();
|
||||
void testReadKeys();
|
||||
|
||||
void testIncorrectSection();
|
||||
|
||||
private:
|
||||
void cleanupTestFiles();
|
||||
|
||||
|
@ -3735,5 +3737,13 @@ void tst_QSettings::testReadKeys()
|
|||
QCOMPARE(readValues, expectedValues);
|
||||
}
|
||||
|
||||
void tst_QSettings::testIncorrectSection()
|
||||
{
|
||||
QVERIFY(QFile::exists(":/incorrectsection.ini"));
|
||||
QSettings s(":/incorrectsection.ini", QSettings::IniFormat);
|
||||
|
||||
QCOMPARE(s.status(), QSettings::FormatError);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QSettings)
|
||||
#include "tst_qsettings.moc"
|
||||
|
|
Loading…
Reference in New Issue