Patchwork [2,of,2] patch from David.Eckhardt@cs.cmu.edu to support factotum passwords with single quotes

login
register
mail settings
Submitter Jeff Sickel
Date Nov. 24, 2014, 4:44 p.m.
Message ID <4b390095b93ba15beee4.1416851064@cagoan0.buf.io>
Download mbox | patch
Permalink /patch/6841/
State Superseded
Headers show

Comments

Jeff Sickel - Nov. 24, 2014, 4:44 p.m.
# HG changeset patch
# User Jeff Sickel <jas@corpus-callosum.com>
# Date 1416848986 21600
#      Mon Nov 24 11:09:46 2014 -0600
# Branch stable
# Node ID 4b390095b93ba15beee48cf4394cde0014b66bcd
# Parent  8913ec66bd1e4c9dd7f4f50c96e8d6d0e3dd963a
patch from David.Eckhardt@cs.cmu.edu to support factotum passwords with single quotes
Matt Mackall - Nov. 24, 2014, 8:12 p.m.
On Mon, 2014-11-24 at 11:44 -0500, Jeff Sickel wrote:
> # HG changeset patch
> # User Jeff Sickel <jas@corpus-callosum.com>
> # Date 1416848986 21600
> #      Mon Nov 24 11:09:46 2014 -0600
> # Branch stable
> # Node ID 4b390095b93ba15beee48cf4394cde0014b66bcd
> # Parent  8913ec66bd1e4c9dd7f4f50c96e8d6d0e3dd963a
> patch from David.Eckhardt@cs.cmu.edu to support factotum passwords with single quotes

Reminder:

http://mercurial.selenic.com/wiki/ContributingChanges#Submission_checklist

David's name needs to be in the user line above, and the summary is not
in our standard format ("factotum: ...").

> +                                passwd = passwd[1:len(passwd)-1].replace("''","'")

Check-code and the test suite will reject the coding style here.

Patch

diff -r 8913ec66bd1e -r 4b390095b93b hgext/factotum.py
--- a/hgext/factotum.py	Mon Nov 24 11:00:58 2014 -0600
+++ b/hgext/factotum.py	Mon Nov 24 11:09:46 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:len(passwd)-1].replace("''","'")
+                            else:
+                                raise util.Abort(_('malformed password string'))
+                        return (user, passwd)
             except (OSError, IOError):
                 raise util.Abort(_('factotum not responding'))
         finally: