summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorJiDe Zhang <zccrs@live.com>2018-08-16 17:18:22 +0800
committerJiDe Zhang <zccrs@live.com>2018-08-27 11:29:14 +0000
commite31febb024782406243179e7ec24e535daf5e6a9 (patch)
treebd0686618161cad01eb9c482dee10ae29df19e88 /src/corelib
parentf0066cae8f0aea4af06a43219dc3351062e1e757 (diff)
QSysInfo(linux): Use UTF-8 format read file
...Of the "readEtcFile" function According to https://www.freedesktop.org/software/systemd/man/os-release.html it says "All strings should be in UTF-8 format". Change-Id: Icd2d75eca2ac7273c7f587a1e3c0430cc6d2c31d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index a369bbe490..6c608dab74 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2142,11 +2142,20 @@ struct QUnixOSVersion
static QString unquote(const char *begin, const char *end)
{
+ // man os-release says:
+ // Variable assignment values must be enclosed in double
+ // or single quotes if they include spaces, semicolons or
+ // other special characters outside of A–Z, a–z, 0–9. Shell
+ // special characters ("$", quotes, backslash, backtick)
+ // must be escaped with backslashes, following shell style.
+ // All strings should be in UTF-8 format, and non-printable
+ // characters should not be used. It is not supported to
+ // concatenate multiple individually quoted strings.
if (*begin == '"') {
Q_ASSERT(end[-1] == '"');
- return QString::fromLatin1(begin + 1, end - begin - 2);
+ return QString::fromUtf8(begin + 1, end - begin - 2);
}
- return QString::fromLatin1(begin, end - begin);
+ return QString::fromUtf8(begin, end - begin);
}
static QByteArray getEtcFileContent(const char *filename)
{