[pass] Fixes to keepassx2pass.py script to handle empty passwords and entry names containing slash ('/') characters (take 2)

Von Welch von at vwelch.com
Tue Feb 12 04:08:30 CET 2013


I believe attachment on my last email got scrubbed, including inline this time.

Von

>From d500238fbbd421b69d53a03546a1b93641211ce9 Mon Sep 17 00:00:00 2001
From: Von Welch <von at vwelch.com>
Date: Mon, 11 Feb 2013 21:08:25 -0500
Subject: [PATCH 1/2] keepassx2pass.py: Handle empty password.

---
 contrib/keepassx2pass.py |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/keepassx2pass.py b/contrib/keepassx2pass.py
index 6043690..3bab60a 100755
--- a/contrib/keepassx2pass.py
+++ b/contrib/keepassx2pass.py
@@ -17,7 +17,8 @@ def path_for(element, path=''):
 def password_data(element):
     """ Return password data and additional info if available from
     password entry element. """
-    ret = element.find('password').text + "\n"
+    passwd = element.find('password').text
+    ret = passwd + "\N" if passwd else "\N"
     for field in ['username', 'url', 'comment']:
         fel = element.find(field)
         if fel.text is not None:
--
1.7.10.2 (Apple Git-33)


>From af94c7955d647a34f94908e9cc84773f893b8ce1 Mon Sep 17 00:00:00 2001
From: Von Welch <von at vwelch.com>
Date: Mon, 11 Feb 2013 21:36:27 -0500
Subject: [PATCH 2/2] keepassx2pass.py: Handle entries with '/' in title,
 replace with '|'

---
 contrib/keepassx2pass.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/keepassx2pass.py b/contrib/keepassx2pass.py
index 3bab60a..6cf2268 100755
--- a/contrib/keepassx2pass.py
+++ b/contrib/keepassx2pass.py
@@ -11,7 +11,7 @@ from xml.etree import ElementTree

 def path_for(element, path=''):
     """ Generate path name from elements title and current path """
-    title = element.find('title').text
+    title = element.find('title').text.replace("/", "|")
     return '/'.join([path, title])

 def password_data(element):
--
1.7.10.2 (Apple Git-33)



More information about the Password-Store mailing list