Skip to content

Commit 047a07e

Browse files
committed
Adjusted desktop file validation for TryExec. An invalid value here is actually a valid state (LP #1754888)
1 parent 381ca42 commit 047a07e

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ MenuLibre NEWS
77
. Delay menu updates for 1 second to prevent file writing collisions
88
. Added GTK to desktop entry categories
99
. Added OnlyShowIn to desktop entry for known supported desktops
10+
. Adjusted desktop file validation for "TryExec". An invalid value here
11+
is actually a valid state. (LP #1754888)
1012
- Bug Fixes:
1113
. Fix infinite loop entered when deleting a file in search mode
1214
(by disabling deletions while in search mode) (LP: #1751616)

menulibre/util.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,9 @@ def determine_bad_desktop_files():
567567
for line in result.stderr.decode().split('\n'):
568568
matches = re.match(r'^Failed to load "(.+\.desktop)"$', line)
569569
if matches:
570-
bad_desktop_files.append(matches.groups()[0])
570+
desktop_file = matches.groups()[0]
571+
if validate_desktop_file(desktop_file):
572+
bad_desktop_files.append(matches.groups()[0])
571573

572574
# Alphabetical sort on bad desktop file paths
573575
bad_desktop_files.sort()
@@ -648,6 +650,9 @@ def validate_desktop_file(desktop_file): # noqa
648650
% ('Type', type_key, GLib.KEY_FILE_DESKTOP_TYPE_APPLICATION))
649651

650652
# Validating 'try exec' if its present
653+
# Invalid TryExec is a valid state. "If the file is not present or if it
654+
# is not executable, the entry may be ignored (not be used in menus, for
655+
# example)."
651656
try:
652657
try_exec = keyfile.get_string(start_group,
653658
GLib.KEY_FILE_DESKTOP_KEY_TRY_EXEC)
@@ -657,16 +662,9 @@ def validate_desktop_file(desktop_file): # noqa
657662
else:
658663
try:
659664
if len(try_exec) > 0 and find_program(try_exec) is None:
660-
# Translators: This error is displayed when a failing desktop
661-
# file contains an invalid path to an executable file.
662-
return (_('%s program \'%s\' has not been found in the'
663-
' PATH') % ('TryExec', try_exec))
665+
return False
664666
except Exception as e:
665-
# Translators: This error is displayed when a failing desktop
666-
# file contains an invalid command to execute.
667-
return (_('%s program \'%s\' is not a valid shell command '
668-
'according to GLib.shell_parse_argv, error: %s')
669-
% ('TryExec', try_exec, e))
667+
return False
670668

671669
# Validating executable
672670
try:

po/menulibre.pot

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2018-03-16 06:52-0400\n"
11+
"POT-Creation-Date: 2018-03-16 20:19-0400\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -894,43 +894,39 @@ msgstr ""
894894
#. Translators: This error is displayed when a desktop file cannot
895895
#. be correctly read by MenuLibre. A (possibly untranslated) error
896896
#. code is displayed.
897-
#: ../menulibre/util.py:617
897+
#: ../menulibre/util.py:619
898898
#, python-format
899899
msgid "Unable to load desktop file due to the following error: %s"
900900
msgstr ""
901901

902902
#. Translators: This error is displayed when the first group in a
903903
#. failing desktop file is incorrect. "Start group" can be safely
904904
#. translated.
905-
#: ../menulibre/util.py:632
905+
#: ../menulibre/util.py:634
906906
#, python-format
907907
msgid "Start group is invalid - currently '%s', should be '%s'"
908908
msgstr ""
909909

910910
#. Translators: This error is displayed when a required key is
911911
#. missing in a failing desktop file.
912-
#: ../menulibre/util.py:642 ../menulibre/util.py:676
912+
#: ../menulibre/util.py:644 ../menulibre/util.py:674
913913
#, python-format
914914
msgid "%s key not found"
915915
msgstr ""
916916

917917
#. Translators: This error is displayed when a failing desktop file
918918
#. has an invalid value for the provided key.
919-
#: ../menulibre/util.py:647
919+
#: ../menulibre/util.py:649
920920
#, python-format
921921
msgid "%s value is invalid - currently '%s', should be '%s'"
922922
msgstr ""
923923

924-
#. Translators: This error is displayed when a failing desktop
925-
#. file contains an invalid path to an executable file.
926-
#: ../menulibre/util.py:662 ../menulibre/util.py:680
924+
#: ../menulibre/util.py:678
927925
#, python-format
928926
msgid "%s program '%s' has not been found in the PATH"
929927
msgstr ""
930928

931-
#. Translators: This error is displayed when a failing desktop
932-
#. file contains an invalid command to execute.
933-
#: ../menulibre/util.py:667 ../menulibre/util.py:683
929+
#: ../menulibre/util.py:681
934930
#, python-format
935931
msgid ""
936932
"%s program '%s' is not a valid shell command according to GLib."
@@ -939,6 +935,6 @@ msgstr ""
939935

940936
#. Translators: This error is displayed for a failing desktop file where
941937
#. errors were detected but the file seems otherwise valid.
942-
#: ../menulibre/util.py:689
938+
#: ../menulibre/util.py:687
943939
msgid "Unknown error. Desktop file appears to be are valid."
944940
msgstr ""

0 commit comments

Comments
 (0)