! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
[PATCH] Fix for simple_parse_line when ] is used in the line.
Status:
RESOLVED: FIXED
Product:
Libxfce4util
Component:
General

Comments

Description Eric Koegel editbugs 2011-11-14 21:05:37 CET
Created attachment 3956 
Patch to fix simple_parse_line in xfce-rc-simple.c to handle multiple ] characters in a line.

When the line variable of simple_parse_line has a ']' delimiter in it, simple_parse_line returns everything up to that point. This patch makes it so everything up to the last ']' is returned.
Fixes a bug in xfdesktop where filenames have a ] in them (such as file[1].c).
Comment 1 Nick Schermer editbugs 2011-11-18 13:00:00 CET
What kind of keys are not parsed exactly? If the key says "Value=file[1].c" in the text file?
Comment 2 Eric Koegel editbugs 2011-11-18 13:54:52 CET
  Sorry, I didn't include the link to the bug in xfdesktop: https://bugzilla.xfce.org/show_bug.cgi?id=2975
Basically xfdesktop uses xfce4util to create an rc file usually located at ~/.config/xfce4/desktop/icons.screen#.rc In that file it stores the filename as the group name and the icon's position as values of that. The way xfce4util is currently written, it will return the after the first ] is located, but that will fail if the filename is something like file[1].c since the rc file will be:

[file[1].c]
row=8
col=11

  Which means simple_parse_line would return "file[1" and not correctly match the entry. The patch I created fixes it to grab the last ] and ignore any text after that, in the event there's a comment embedded at the end of the line.
  Hopefully, this helps clarify things. If you need me to clean up the patch or need more info, let me know.
Comment 3 Eric Koegel editbugs 2012-01-07 04:33:56 CET
http://git.xfce.org/xfce/xfdesktop/tree/src/xfdesktop-file-icon-manager.c
1783:xfdesktop_file_icon_manager_get_cached_icon_position
calls if(xfce_rc_has_group(rcfile, name))

http://git.xfce.org/xfce/libxfce4util/tree/libxfce4util/xfce-rc.c
xfce-rc.c:407:xfce_rc_has_group (const XfceRc *rc, const gchar *group)
calls _xfce_rc_config_has_group

http://git.xfce.org/xfce/libxfce4util/tree/libxfce4util/xfce-rc-config.c
xfce-rc-config.c:331:_xfce_rc_config_has_group (const XfceRc *rc,
calls _xfce_rc_simple_has_group

http://git.xfce.org/xfce/libxfce4util/tree/libxfce4util/xfce-rc-simple.c
xfce-rc-simple.c:928:_xfce_rc_simple_has_group (const XfceRc *rc
and we get to
xfce-rc-simple.c:667: if (!simple_parse_line (line, &section, &key, &value, &locale))

Where the bug prevents xfce_rc_has_group from returning true because
xfce-rc-simple.c:330: for (q = ++p; *q != '\0' && *q != ']'; ++q)
stops at the first ']' rather than the last in the line.

So it's the group name and not a key=value pair.
Comment 4 Nick Schermer editbugs 2012-01-07 11:59:04 CET
Fixed in 97f0ec4.

Bug #8150

Reported by:
Eric Koegel
Reported on: 2011-11-14
Last modified on: 2012-01-07

People

Assignee:
Xfce Bug Triage
CC List:
1 user

Version

Version:
Unspecified

Attachments

Additional information