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 390532 - GKeyFile checks breaks existing applications
GKeyFile checks breaks existing applications
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.12.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2006-12-29 02:11 UTC by Josselin Mouette
Modified: 2007-01-10 12:59 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
Add space to allowed key characters (556 bytes, patch)
2006-12-29 02:12 UTC, Josselin Mouette
none Details | Review
Accept space in key names with corresponding tests (2.83 KB, patch)
2006-12-31 19:42 UTC, Loïc Minier
none Details | Review
Reverts stricter KeyFile checks and outputs critical warnings instead (12.11 KB, patch)
2006-12-31 22:04 UTC, Loïc Minier
none Details | Review

Description Josselin Mouette 2006-12-29 02:11:36 UTC
Older versions of gnucash used to generate key files with spaces in the keys. Which means that with glib 2.12.6 it now fails to re-read them.

The solution would be to allow spaces in key names. It is not very clean, but I don't think it does harm either.
Comment 1 Josselin Mouette 2006-12-29 02:12:25 UTC
Created attachment 79018 [details] [review]
Add space to allowed key characters
Comment 2 Matthias Clasen 2006-12-29 04:48:28 UTC
hmm, space is a spectacularly bad character to allow in keys, if only because it won't work at the beginning or end of keys. Consider cases like:

Name = foo  # sets the key "Name", trailing space is stripped
 Name=bar  # sets the key "Name", initial space is stripped
Name [de] = bar  # sets the de locale value for the key "Name "
Comment 3 Josselin Mouette 2006-12-29 09:30:40 UTC
Indeed, spaces around the = sign make it tricky. Do you have an idea of how to allow gnucash to re-read those old files then?
Comment 4 Matthias Clasen 2006-12-29 18:27:58 UTC
Convert them to an acceptable format before using gkeyfile to load them ?
Should not be more than 5 lines, using g_file_[get|set)_contents() and
the C equivalent of

s/^ *//
s/ *=/=/
s/ \([^=]*=\)/_\1/
Comment 5 Thomas Bushnell, BSG 2006-12-31 04:57:44 UTC
I'm confused why Matthias Clasen says that spaces are a problem.  According to gnucash upstream, before this change, \s was documented to be a matching space at the beginning or end of a key.
Comment 6 Matthias Clasen 2006-12-31 05:05:09 UTC
\s is only recognized in values, not in keys. This has not changed. What we are discussing here is problems with allowing literal spaces in keys.
Comment 7 Loïc Minier 2006-12-31 19:42:25 UTC
Created attachment 79122 [details] [review]
Accept space in key names with corresponding tests

I personally wonder whether a localized key name with spaces at the end should be treated as such; this patch will support key names with a space in the middle but will refuse spaces at the end or the beginning of key names.
Comment 8 Loïc Minier 2006-12-31 22:04:37 UTC
Created attachment 79126 [details] [review]
Reverts stricter KeyFile checks and outputs critical warnings instead

Perhaps it would be better to back off the backward-incompatible changes in GKeyFile and only outputs critical warnings during the 2.12 lifecycle?

I've uploaded the attached patch to achieve this in Debian.
Comment 9 Matthias Clasen 2007-01-02 05:57:26 UTC
2007-01-01  Matthias Clasen  <mclasen@redhat.com>

        * glib/gkeyfile.c: Convert the recently added stricter
        keyfile syntax checks into critical warnings, to help apps
        which do bad things with key files. Note that the
        stricter checks will remain in place for 2.14.  (#390532,
        Loïc Minier)

        * tests/keyfile-test.c: Adapt

Comment 10 paul 2007-01-08 14:46:26 UTC
ok, from what i understand in here, i have a whole directory of files .desktop files that are ok
however, without the patch in comment #8, nautilus for example doesn't want to pass on any file associations

without the patch
http://img89.imageshack.us/img89/2113/withoutmc8.png

with the patch
http://img101.imageshack.us/img101/7164/withpn6.png

not just tar.gz files
pngs, jpegs, truetype fonts, plain text files, etc...
is it too strict?
Comment 11 Matthias Clasen 2007-01-08 15:09:34 UTC
The patch is in 2.12.7. However, the stricter checks remain in place in trunk. 
Applications need to be fixed to respect the file format
Comment 12 Wouter Bolsterlee (uws) 2007-01-10 12:45:01 UTC
Matthias, what do you suggest for bug #394262 wrt this issue?
Comment 13 Matthias Clasen 2007-01-10 12:51:26 UTC
I recommend that the desktop entry spec be amended to allow /, +, -, _ in keys
and whatever other characters happen to be used. That is not really a problem.
Allowing space, however, is a bit problematic.
Comment 14 Wouter Bolsterlee (uws) 2007-01-10 12:59:05 UTC
retitling