← Back to team overview

zeitgeist team mailing list archive

[Bug 526357] Re: error on parsing empty application name from malformed desktop entry

 

Fixed, thanks.

** Project changed: zeitgeist-dataproviders => zeitgeist

** Changed in: zeitgeist
   Importance: Undecided => Medium

** Changed in: zeitgeist
       Status: New => Fix Released

** Changed in: zeitgeist
     Assignee: (unassigned) => Siegfried Gevatter (rainct)

** Changed in: zeitgeist
    Milestone: None => 0.3.3

-- 
error on parsing empty application name from malformed desktop entry
https://bugs.launchpad.net/bugs/526357
You received this bug notification because you are a member of Zeitgeist
Framework Team, which is a direct subscriber.

Status in Zeitgeist Framework: Fix Released

Bug description:

I've got a malformed Desktop Entry installed user-related; malformed because the "Exec=*" line in it doesn't have any application string defined and it should [1]. Anyway, it's there, malformed, and raises an error.

****************
Traceback (most recent call last):
  File "/home/mtou/zeitgeist/zeitgeist/zeitgeist/../zeitgeist-datahub.py", line 108, in _update_db_async
    events = self._sources_queue[0].get_items()
  File "/home/mtou/zeitgeist/zeitgeist/zeitgeist/../_zeitgeist/loggers/zeitgeist_base.py", line 84, in get_items
    return self._get_items()
  File "/home/mtou/zeitgeist/zeitgeist/zeitgeist/../_zeitgeist/loggers/datasources/recent.py", line 290, in _get_items
    desktopfile = self._find_desktop_file_for_application(application)
  File "/home/mtou/zeitgeist/zeitgeist/zeitgeist/../_zeitgeist/loggers/datasources/recent.py", line 263, in _find_desktop_file_for_application
    line.split("=", 1)[-1].strip().split()[0] == application:
IndexError: list index out of range

**************
Fix :
replace lines ~261 in _zeitgeist/loggers/datasources/recent.py 
from
---
if line.startswith("Exec") and \
line.split("=", 1)[-1].strip().split()[0] == application:
    return unicode(fullname)
---
to
---
execlinepattern = re.compile("^Exec\b*=\b*\S+")
if execlinepattern.match(line) is not None and \
line.split("=", 1)[-1].strip().split()[0] == application:
    return unicode(fullname)
---

Feel free to push the pattern upward to optimise.

One could even use full regexp extraction to get the application, but I'm not familiar enough with python to code it.

Appears on zeitgeist trunk and ubuntu jaunty PPA package.



[1] http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html





References