mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
test: fix passwd_sanitize()
If any of the variables is empty the output is completely messed up, because replace("", "FOO") puts "FOO" before every single character. I don't have my full name configured, and this is what I get: USER_FULL_NAME=USER_FULL_NAME=USER_FULL_NAME USER_FULL_NAMEsUSER_FULL_NAMEtUSER_FULL_NAMEdUSER_FULL_NAMEoUSER_FULL_NAMEuUSER_FULL_NAMEtUSER_FULL_NAME USER_FULL_NAME=USER_FULL_NAME=USER_FULL_NAME Let's check for empty strings before doing any replace. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
parent
6a20478abb
commit
ff5f141bf2
1 changed files with 6 additions and 1 deletions
|
@ -711,7 +711,12 @@ name = pw.pw_gecos.partition(",")[0]
|
|||
fqdn = socket.getfqdn()
|
||||
|
||||
for l in sys.stdin:
|
||||
l = l.replace(user, "USERNAME").replace(fqdn, "FQDN").replace(".(none)","").replace(name, "USER_FULL_NAME")
|
||||
if user:
|
||||
l = l.replace(user, "USERNAME")
|
||||
if fqdn:
|
||||
l = l.replace(fqdn, "FQDN").replace(".(none)","")
|
||||
if name:
|
||||
l = l.replace(name, "USER_FULL_NAME")
|
||||
sys.stdout.write(l)
|
||||
'
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue