[PATCH] Re: Bug in Sawfish apps-menu.jl

Teika Kazura <teika lavabit com> writes:

> (To: sawfish-list, cc: Matthew Love)
> Hi, Matthew. We've got a bug in apps-menu.jl. I wonder if it would be
> possible for you to fix it.
> It's that if erroneous *.desktop file or broken symlink is there, then
> Sawfish doesn't start. An example of such file is:
> https://bugzilla.gnome.org/attachment.cgi?id=152072
> How are you doing?
> With best regards,
> Teika (Teika kazura)

Ok, it appears the culprit was the (read-from-string) function, which
throws errors when the first character is a ";" or if a '#' is anywhere
in the string.  This function was being called in the (build-cat-list)
function to parse out the various categories.  It was a bad idea, and I
had meant to change that a while ago, to use (read-from-string) for that
purpose, as the (get-key-value) function used elsewhere in the
apps-menu.jl was meant to replace its use.  It is now replaced and all should
be well in that regard, a leading ";" should now return an empty string
and as a result leave that entry out of the final list, but at least it
won't crash anything.

As far as symlinks go, it might be best to ignore them completely, I've
added this idea into the following patch, by checking if the file is a
symlink initially along with the other checks in (generate-menu-entry),
otherwise, that line in the patch can be ignored.


diff --git a/lisp/sawfish/wm/ext/apps-menu.jl b/lisp/sawfish/wm/ext/apps-menu.jl
index 1c62d64..34ceb75 100644
--- a/lisp/sawfish/wm/ext/apps-menu.jl
+++ b/lisp/sawfish/wm/ext/apps-menu.jl
@@ -67,6 +67,7 @@ set this to non-nil.")
   (defvar apps-menu-alphabetize t
     "Sort the apps menu alphabetically.")
   (defvar apps-menu-lang nil
     "Language for applications menu, in string. Default is set from locale.")
@@ -94,8 +95,9 @@ set this to non-nil.")
 	  (do ((mcount 0 (1+ mcount)))
 	      ((or (string= (substring instring mcount (+ mcount 1)) "\n")
 		   (string= (substring instring mcount (+ mcount 1)) key)
-		   (= mcount (- mlength 2))
-		   (= mcount 398)) mcount)))))
+		   (= mcount (- mlength 1))
+		   (= mcount 398)) 
+	       mcount)))))
   (define (get-desktop-key instring)
     (if (> (length instring) 3)
@@ -255,7 +257,7 @@ set this to non-nil.")
   ;; list
   (define (build-cat-list line)
     (if (> (length line) 1)
-	(let ((this-cat (prin1-to-string (read-from-string line))))
+	(let ((this-cat (substring line 0 (get-key-break line ";"))))
 	  (cons this-cat
 		(if (< (length this-cat) (length line))
@@ -329,7 +331,8 @@ exile it."
     "Generate a menu entry to run the program specified in the the
 .desktop file `desk-file'."
     (if (and (not (file-directory-p desk-file))
-	     (desktop-file-p desk-file))
+	     (desktop-file-p desk-file)
+	     (not (file-symlink-p desk-file)))
 	(let ((fdo-list (fdo-check-exile (parse-desktop-file desk-file))))
 	  (if apps-menu-ignore-no-display
 	      (let ((a (assoc "NoDisplay" fdo-list)))

M.R. Love

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