[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#757383: [checks/menu-format] Detect MimeType in desktop file without %f, %F, %u or %U in Exec



Package: lintian
Version: 2.5.25
Severity: wishlist
Tags: patch

Dear maintainer,

when a package registers for a mime type like

  MimeType=application/text-plain

in its desktop file, it should then also use one of %u, %U, %f or %F in
the Exec [1] key, like:

  Exec=gedit %U

In fact if the %U was missing at least Gnome 3 (but possibly other
dekstop enviroments) will not even consider the application for opening
a specific file.

This should be easily detectable with high confidence.

Best regards
Niklas Fiekas

[1] http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html
diff --git a/checks/menu-format.desc b/checks/menu-format.desc
index 42a6650..6f9e583 100644
--- a/checks/menu-format.desc
+++ b/checks/menu-format.desc
@@ -379,6 +379,15 @@ Info: The header on this line of the desktop entry has been deprecated in the
  useful for checking the syntax of desktop entries.
 Ref: http://standards.freedesktop.org/desktop-entry-spec/1.0/apc.html
 
+Tag: desktop-mime-but-no-exec-code
+Severity: normal
+Certainty: possible
+Info: The desktop entry lists support for at least one mime type, but does not
+ provide codes like %f, %F, %u or %U for the Exec key.
+ .
+ If the application can indeed handle files of the listed mime types, it should
+ specify a way to pass the filenames as parameters.
+
 Tag: deprecated-kdelnk-file
 Severity: important
 Certainty: certain
diff --git a/checks/menu-format.pm b/checks/menu-format.pm
index ab94245..b68411a 100644
--- a/checks/menu-format.pm
+++ b/checks/menu-format.pm
@@ -700,6 +700,15 @@ sub verify_desktop_file {
             tag 'desktop-entry-limited-to-environments', $file;
         }
     }
+
+    # Check that the Exec tag specifies how to pass a filename if MimeType
+    # tags are present.
+    if ($file =~ m,^usr/share/applications/, and defined $vals{'MimeType'}) {
+        unless(defined $vals{'Exec'} and $vals{'Exec'} =~ m,(^|[^%])%[fFuU]/,) {
+            tag 'desktop-mime-but-no-exec-code', $file;
+        }
+    }
+
     return;
 }
 

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: