aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJos van den Oever <jos@vandenoever.info>2018-12-29 18:27:13 +0100
committerJos van den Oever <jos@vandenoever.info>2018-12-30 13:17:49 +0100
commitf403d09d0b4958d151790f312ec998ef39632b1a (patch)
treea26b23b1c26efb831107334fedf77f4fbe955a07 /src
parentd90a37b5a1d892d7b0ff7cc3b56c8a6e8c4bfe1a (diff)
downloadkconfig-f403d09d0b4958d151790f312ec998ef39632b1a.tar.gz
kconfig-f403d09d0b4958d151790f312ec998ef39632b1a.tar.bz2
Fix a regression introduced in 6a1852
Summary: Bytes from 'Strings' of type GroupString and KeyString should not be escaped because they are valid UTF-8. Only instances of ValueString should be escaped. This fixes the failing test KConfigTest::testEncoding Test Plan: Ran `ninja test` and found no errors. Reviewers: dfaure, arichardson, apol, aacid, ngraham Reviewed By: apol Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D17856
Diffstat (limited to 'src')
-rw-r--r--src/core/kconfigini.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp
index 39e59364..b6749731 100644
--- a/src/core/kconfigini.cpp
+++ b/src/core/kconfigini.cpp
@@ -673,7 +673,12 @@ QByteArray KConfigIniBackend::stringToPrintable(const QByteArray &aString, Strin
switch (s[i]) {
default:
// The \n, \t, \r cases (all < 32) are handled below; we can ignore them here
- if (((unsigned char)s[i]) < 32 || ((unsigned char)s[i]) >= 127) {
+ if (((unsigned char)s[i]) < 32) {
+ goto doEscape;
+ }
+ // GroupString and KeyString should be valid UTF-8, but ValueString
+ // can be a bytearray with non-UTF-8 bytes that should be escaped.
+ if (type == ValueString && ((unsigned char)s[i]) >= 127) {
goto doEscape;
}
*data++ = s[i];