Universal escaping in KConfigINI: Summary and patch

Andreas Hartmetz ahartmetz at gmail.com
Thu May 24 02:55:56 BST 2007

Hello list,

Here is the proposed patch to implement escaping in KConfigINI to make it safe 
to pass any QString as a group name, key or value. Values have always been 
more or less safe, except for control chars (chars < 32), which were 
previously written literally. This was not really "dangerous", but might lead 
to weird effects when displaying or processing a config file with arbitrary 

The patch also drops special treatment for group names in which '[' and ']' 
were encoded as "[[" and "]]" respectively.
It encodes as \x<nn> (<nn> being two lowercase hex chars):
- chars with value < 32 except for '\n' (LF), '\r' (CR), and '\t' (tab).
  There already are standard encodings for them, "\n", "\r", and "\t".
- '['
- ']'
- '='

This has the advantages of safety and making .INI-format config files 
extremely easy to parse because all chars with special meaning will, where 
they appear literally, always have their special meaning. This is relevant 
for config file conversion scripts that applications use to upgrade their 
config files to a new format when necessary.

I hope this is close enough to what was discussed on IRC.
The patch also contains some porting to the new QByteArray, which is 
automatically zero-terminated, and has a constData() function that avoids 
deep copying the raw data.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: kconfigini.cpp.patch
Type: text/x-diff
Size: 13400 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070524/1fb9cd96/attachment.patch>

More information about the kde-core-devel mailing list