RFC: escape strings in KConfigBase

Andreas Hartmetz ahartmetz at gmail.com
Tue May 15 09:06:25 BST 2007

On Tuesday 15 May 2007 08:17:27 Olivier Goffart wrote:
> Le mardi 15 mai 2007, Andreas Hartmetz a écrit :
> > Hello list,
> >
> > I noticed that KConfigBase has some "forbidden" chars in certain fields,
> > quote:
> > "the '=' char is not allowed in keys and the ']' char is not allowed in a
> > group name."
> > ...and another char, ',' by default, is also forbidden if you want to use
> > the (very convenient) list read/write functions.
> > This is not state of the art, dangerous (who knows which strings happen
> > to turn up in your config file), and cumbersome.
> I also already had the problem (in my case this was with ',' in lists)
> > I can come up with three possible solutions:
> > - Auto-escape all strings, using the backslash notation if nothing better
> > (i.e. faster to parse and still human readable) exists.
> > - Provide an escape function that takes the chars to escape as a
> > parameter - Add Escape/NoEscape as flags to the write/read functions.
> I vote for automatic escape using backslash notation.
> I don't see any case where you wouldn't want to escape.

I was just worried about speed, which is probably rather silly given today's 
CPU speeds and typical config file sizes (~1 to 10 kb). Let's just say that  
backslash-escaped notation will be the standard unless there are serious 
concerns. I'll post an API change request (even though no function signatures 
will change :] ) in about two days.

More information about the kde-core-devel mailing list