Merge lp:~alecu/unity-scope-click/broken-dot-desktop into lp:unity-scope-click/devel

Proposed by Alejandro J. Cura
Status: Merged
Approved by: dobey
Approved revision: 224
Merged at revision: 224
Proposed branch: lp:~alecu/unity-scope-click/broken-dot-desktop
Merge into: lp:unity-scope-click/devel
Diff against target: 22 lines (+5/-0)
2 files modified
scope/click/interface.cpp (+4/-0)
scope/tests/applications/user/semi-broken.desktop (+1/-0)
To merge this branch: bzr merge lp:~alecu/unity-scope-click/broken-dot-desktop
Reviewer Review Type Date Requested Status
dobey (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+217514@code.launchpad.net

Commit message

Check for valid .desktop files

To post a comment you must log in.
Revision history for this message
dobey (dobey) wrote :

Do we not need to trap the LogicException here? I had thought that we would need to do so, as well as ignoring otherwise broken .desktop files which are just text but not .desktop files.

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote :

> Do we not need to trap the LogicException here? I had thought that we would
> need to do so, as well as ignoring otherwise broken .desktop files which are
> just text but not .desktop files.

We don't need to trap that exception, because the .has_group() method is declared noexcept, and if the DESKTOP_FILE_GROUP is not present then that's enough to catch every case. I'm testing for that with the broken.desktop file, which has 100 bytes of zero, and with semi-broken.desktop, which has just a text line, and with the has_group() fix both cases are handled well.

Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scope/click/interface.cpp'
2--- scope/click/interface.cpp 2014-04-22 22:24:46 +0000
3+++ scope/click/interface.cpp 2014-04-28 22:12:28 +0000
4@@ -136,6 +136,10 @@
5 auto enumerator = [&result, &installTimes, this, search_query, include_desktop_results]
6 (const unity::util::IniParser& keyFile, const std::string& filename)
7 {
8+ if (keyFile.has_group(DESKTOP_FILE_GROUP) == false) {
9+ qWarning() << "Broken desktop file:" << QString::fromStdString(filename);
10+ return;
11+ }
12 if (is_visible_app(keyFile) == false) {
13 return; // from the enumerator lambda
14 }
15
16=== added file 'scope/tests/applications/user/broken.desktop'
17Binary files scope/tests/applications/user/broken.desktop 1970-01-01 00:00:00 +0000 and scope/tests/applications/user/broken.desktop 2014-04-28 22:12:28 +0000 differ
18=== added file 'scope/tests/applications/user/semi-broken.desktop'
19--- scope/tests/applications/user/semi-broken.desktop 1970-01-01 00:00:00 +0000
20+++ scope/tests/applications/user/semi-broken.desktop 2014-04-28 22:12:28 +0000
21@@ -0,0 +1,1 @@
22+semi broken file

Subscribers

People subscribed via source and target branches

to all changes: