diff options
author | Jos van den Oever <jos@vandenoever.info> | 2018-12-18 13:55:56 +0100 |
---|---|---|
committer | Jos van den Oever <jos@vandenoever.info> | 2018-12-18 20:56:55 +0100 |
commit | 6a185285ae44ed182dbab9206b9092f78c7d3714 (patch) | |
tree | f85cb3e9f003d4383a938b9f7a342f91fa10508c /src | |
parent | e4b002e7ae07272cd63921d65ec299c66f5c36ab (diff) | |
download | kconfig-6a185285ae44ed182dbab9206b9092f78c7d3714.tar.gz kconfig-6a185285ae44ed182dbab9206b9092f78c7d3714.tar.bz2 |
Escape bytes that are larger than or equal to 127 in config files
Summary:
UserBase tells me that KDE configuration files are encoded in UTF-8.
https://userbase.kde.org/KDE_System_Administration/Configuration_Files
In practice some *rc files have bytes outside that encoding. In my home directory I found two files that are not valid UTF-8.
I searched with
find ~/.config/ -name '*rc' -exec file {} +
which gives these exceptions:
akonadiconsolerc: Non-ISO extended-ASCII text, with very long lines
kmail2rc: Non-ISO extended-ASCII text, with very long lines
In kmail2rc, the offending fields are
[AttachmentView]/State
[CollectionFolderView]/HeaderState
Both are QByteArray values saved from QHeaderView::saveState().
In the instance I found, the offending bytes were 0x81 and 0x84.
akonadiconsolerc had way more of these values. All seem related to saving widget state and hence probably QByteArrays.
The written QByteArray values look very strange. The bytes in the non-printable ASCII range are written as \xXX but the values above 127 are written literally.
The encoding is done by KConfigIniBackend::stringToPrintable. It does not currently escape bytes that are larger than or equal to 127.
Reviewers: dfaure, arichardson, apol
Reviewed By: apol
Subscribers: apol, kde-frameworks-devel
Tags: #frameworks
Differential Revision: https://phabricator.kde.org/D17651
Diffstat (limited to 'src')
-rw-r--r-- | src/core/kconfigini.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/kconfigini.cpp b/src/core/kconfigini.cpp index c7b36efd..39e59364 100644 --- a/src/core/kconfigini.cpp +++ b/src/core/kconfigini.cpp @@ -673,7 +673,7 @@ 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) { + if (((unsigned char)s[i]) < 32 || ((unsigned char)s[i]) >= 127) { goto doEscape; } *data++ = s[i]; |