kwallet2pass.py patch suggestion

Borden Rhodes borden at bordenrhodes.com
Tue Feb 19 08:28:02 CET 2019


Disclaimer: I'm a very amateur programmer still learning python, so I
apologise for the sloppiness of my git diff patch.

My KWallet XML file maps had some keys but no values. When
kwallet2pass.py got to these maps in the XML file, python threw a
"TypeError: cannot concatenate 'str' and 'NoneType' objects" exception
on line 73 because child.text was empty (and automatically assigned
None).

Why would my KWallet export have keys but no values in map files? This
was because the Firefox KWallet integration add-on copied the Firefox
password database fields into KWallet. So there would be keys like
'httprealm' that had no associated value because Firefox didn't assign
one, but the add-on copied the key into KWallet anyway.

So what I did to process this file (so I could avoid having to regex
the XML into something tidier before converting) was make the
following change to the file:

diff --git a/kwallet2pass.py b/kwallet2pass.py
index 2a9034c..78ef738 100644
--- a/kwallet2pass.py
+++ b/kwallet2pass.py
@@ -70,7 +70,7 @@ def import_map(element, path):
     for child in element:
         if child.tag == 'mapentry':
             name = child.attrib['name']
-            text = text + '\n\n' + name + '\n' + child.text
+            text = text + '\n\n' + name + '\n' + str(child.text or '')
             nEntries += 1
             for child2 in child:
                 unexpected(child, path_for(child, npath))

Effectively creating a default (empty) value for when there was a key
but no value. The commit objects will have no correlation to the zx2c4
repo because I generated this using my own local git repo - again, I
apologise.

Anyhow, I want to recommend this as a beginner's fix to the
key-no-value exception that my particular KWallet file has and others
may encounter.

With regards,


More information about the Password-Store mailing list