summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qsettings.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2020-04-14 09:36:04 +0200
committerKai Koehne <kai.koehne@qt.io>2020-04-14 15:51:46 +0200
commit9ba09e26d7fc667355d48a7d26361be6fb20612d (patch)
treee607208086e5fba45e302a3d00514293b976c48e /src/corelib/io/qsettings.cpp
parente7eff98401723ff7e4e8d962405f9af1b53b9759 (diff)
QSettings: Read past UTF-8 BOM even without textcodec support
Try to read past an UTF-8 BOM even if no textcodec support is available, but do set the status to FormatError then. This is in line with the general 'best effort' approach in QSettings. It also allows qmake (that is built without textcodec support) to gracefully load qt.conf files with a UTF-8 BOM, though non-Latin1 characters might still be misrepresented. Fixes: QTBUG-83456 Change-Id: I31b45dc5a8adf7950910897a2b33ae16990d3818 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/corelib/io/qsettings.cpp')
-rw-r--r--src/corelib/io/qsettings.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index b191397e7e..c69ec908ed 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -1673,14 +1673,16 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data,
int sectionPosition = 0;
bool ok = true;
-#if QT_CONFIG(textcodec)
// detect utf8 BOM
const uchar *dd = (const uchar *)data.constData();
if (data.size() >= 3 && dd[0] == 0xef && dd[1] == 0xbb && dd[2] == 0xbf) {
+#if QT_CONFIG(textcodec)
iniCodec = QTextCodec::codecForName("UTF-8");
+#else
+ ok = false;
+#endif
dataPos = 3;
}
-#endif
while (readIniLine(data, dataPos, lineStart, lineLen, equalsPos)) {
char ch = data.at(lineStart);