Escape bytes that are larger than or equal to 127 in config files

Authored by vandenoever on Dec 18 2018, 12:55 PM.

Description

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

Details