After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 547175 - Allow escaping of the comment character in g_key_file_*
Allow escaping of the comment character in g_key_file_*
Status: RESOLVED NOTABUG
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2008-08-10 13:43 UTC by Enrico Tröger
Modified: 2008-08-11 17:00 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Enrico Tröger 2008-08-10 13:43:54 UTC
It would be nice if the comment character in key value file could be escaped with a backslash to be able to use it in keys and in values.

Currently, something like:

[somegroup]
foo=b\#ar

doesn't work, the key 'foo' is ignored because of the '#' character. It would be nice if GLib would recognise the backslash character and allow the '#' char.
Comment 1 Matthias Clasen 2008-08-10 21:56:09 UTC
That shouldn't be necessary. According to the desktop entry spec, 
# should only have special significance at the beginning of a line.

foo=b\#ar doesn't work because \# is not a supported escape sequence.
I'd be surprised if foo=b#ar doesn't work. 

If it doesn't, I'd appreciate a patch that adds a testcase for that to 
glib/tests/keyfile.c
Comment 2 Enrico Tröger 2008-08-11 14:11:54 UTC
For some reason, it didn't work for me without escaping before I reported this. But I tested it again and it works fine with an hash character in a key and/or in a value. So there is actually no need to change this.

The only thing is that you can't define keys which start with an hash character as it is (correctly) recognised as the comment character. I guess use cases for keys starting an hash character are rare and so there is maybe no real need to make the comment character escapable.
Comment 3 Matthias Clasen 2008-08-11 16:08:10 UTC
From the desktop entry spec:

  Key names must contain only the characters A-Za-z0-9-. 
Comment 4 Enrico Tröger 2008-08-11 17:00:10 UTC
Ok, great. GLib does what it should and it does not what it should not.
Thanks for clarification.