factotum: convert Plan 9 quoted string to Python string
authorDavid Eckhardt <David.Eckhardt@cs.cmu.edu>
Tue, 25 Nov 2014 02:31:52 -0600
changeset 23393 c834c0194dbb
parent 23392 d66547df8207
child 23394 b5e2128ce9e6
factotum: convert Plan 9 quoted string to Python string
hgext/factotum.py
--- a/hgext/factotum.py	Tue Nov 25 02:27:31 2014 -0600
+++ b/hgext/factotum.py	Tue Nov 25 02:31:52 2014 -0600
@@ -72,9 +72,14 @@
                 l = os.read(fd, ERRMAX).split()
                 if l[0] == 'ok':
                     os.write(fd, 'read')
-                    l = os.read(fd, ERRMAX).split()
-                    if l[0] == 'ok':
-                        return l[1:]
+                    status, user, passwd = os.read(fd, ERRMAX).split(None, 2)
+                    if status == 'ok':
+                        if passwd.startswith("'"):
+                            if passwd.endswith("'"):
+                                passwd = passwd[1:-1].replace("''", "'")
+                            else:
+                                raise util.Abort(_('malformed password string'))
+                        return (user, passwd)
             except (OSError, IOError):
                 raise util.Abort(_('factotum not responding'))
         finally: