[kupfer] plugin.tracker: Improve shell quoting with tracker-tag



commit 0d34e4da8520d3acd4eecdaa9a46e09a1643a63f
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sun Sep 6 23:14:17 2009 +0200

    plugin.tracker: Improve shell quoting with tracker-tag
    
    We didn't quote anything we sent to tracker-tag which meant that it
    was really broken for some cases: filepaths with spaces, for example,
    or filenames with colons.

 kupfer/plugin/tracker.py |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/kupfer/plugin/tracker.py b/kupfer/plugin/tracker.py
index 54022c2..36bbd31 100644
--- a/kupfer/plugin/tracker.py
+++ b/kupfer/plugin/tracker.py
@@ -103,9 +103,9 @@ def get_tracker_tags(for_file=None):
 			tag = tag.strip()
 			yield tag
 	else:
-		output = popen("tracker-tag --list %s" % for_file).readlines()
+		output = popen("tracker-tag --list '%s'" % for_file).readlines()
 		for tagline in output[1:]:
-			fil, tagstr = tagline.split(": ", 1)
+			fil, tagstr = tagline.rsplit(": ", 1)
 			tags = tagstr.strip().split("|")
 			for t in filter(None, tags):
 				yield t
@@ -182,7 +182,7 @@ class TrackerAddTag (Action):
 	def activate(self, leaf, obj):
 		lpath = leaf.object
 		tag = obj.object
-		utils.launch_commandline("tracker-tag --add=%s %s" % (obj, lpath))
+		utils.launch_commandline("tracker-tag --add='%s' '%s'" % (obj, lpath))
 
 	def requires_object(self):
 		return True
@@ -214,7 +214,7 @@ class TrackerRemoveTag (Action):
 	def activate(self, leaf, obj):
 		lpath = leaf.object
 		tag = obj.object
-		utils.launch_commandline("tracker-tag --remove=%s %s" % (obj, lpath))
+		utils.launch_commandline("tracker-tag --remove='%s' '%s'" % (obj, lpath))
 
 	def requires_object(self):
 		return True



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