From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0r.migadu.com with LMTPS id QHa9J49BjWBnYgEALuJCtg (envelope-from ) for ; Sat, 01 May 2021 13:54:55 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 4ImBI49BjWCuOgAAB5/wlQ (envelope-from ) for ; Sat, 01 May 2021 11:54:55 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3543E1A4F1 for ; Sat, 1 May 2021 13:54:55 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 7EE8E271E8; Sat, 1 May 2021 07:54:37 -0400 (EDT) Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by mail.notmuchmail.org (Postfix) with ESMTPS id 60D3E2717A for ; Sat, 1 May 2021 07:54:31 -0400 (EDT) Received: by mail-ot1-x333.google.com with SMTP id d3-20020a9d29030000b029027e8019067fso870764otb.13 for ; Sat, 01 May 2021 04:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vDsg58aYm7UbaBXyHM2cujHO0TuTyboFnLuxRI8w2gI=; b=fEF7lBZHOmK5mGSJz8ZrPzR4Uumj4VAh9tavGPzMyZTSUI2kiKwhDVmKW8kyV7G4q0 tIQgCV8ypVCw69n+QYlqBfRkA//EyfkzHs1QofyotqQpVFm7p6MGtT5T49M7Rd0ul1rI yM3Zohs+9UU0hen5O6PgPP8Ry0JIk3tYHyOJCMgBP3krVJb1ekBbjSoxHdyYajK6QD4e ZlToViZNfZUIO0Bmv2cO8kesynfvS+FIf2O0dKCSMmUvZi8OuUtrF37iR83vydzeGvEL 2xV8kVHSYi+10vqwvHIQHpDnNKVALh97ToUJIwTQ/R5IKC4cM+Xp4tVQpRdDh9vIaFZk 0NUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vDsg58aYm7UbaBXyHM2cujHO0TuTyboFnLuxRI8w2gI=; b=LRv5ik1J3HGkRsoVhMMqff23GzFOZHgJKKowL7Lfk6eXsHllzQucUK5QBa9na0jBHz 7PXm6/byw+69vmz7n/hXvAJmxPOy/z0hc4ygXcEo42mnKvqw+3R6P68vMqNE5s0Vu0bJ cpjnlWhoXOGXi6LkCiy23wPsbGnO9xyLUwjjD7J6gUAqWVDQLQQnf01QFOD+PxQNpr50 1PQAi00xYGX6rUHdV33V7UU1EMTIyciVlicdkwRDIzqL6ACu9TgYF2hotMKpxUlppP+q G+etOrYtFnaxqbSB6lH+QYo+GL7/57p20gCmaXM2xNaSuvZvZfP4Qt/PtMxIQhNai0UE /7Ng== X-Gm-Message-State: AOAM5312swWmZdJmP0wpOcO7ZiQc05I03gdtHWaqkIzy48AtAL+4Cfec l9aE7wU8JFAvxez3w93flcvyMAAVaFeg8Q== X-Google-Smtp-Source: ABdhPJxyhLQCgpQ84lij4GNxRz3yYtm1Ie/EoO4WtnwWiV4Dc6Gq1HQnb/PBiomxVbQDga192er/pw== X-Received: by 2002:a9d:4c86:: with SMTP id m6mr7332514otf.147.1619870066202; Sat, 01 May 2021 04:54:26 -0700 (PDT) Received: from localhost ([2806:2f0:4060:638f:a2c5:89ff:fe0c:1151]) by smtp.gmail.com with ESMTPSA id t84sm1462298oih.35.2021.05.01.04.54.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 May 2021 04:54:25 -0700 (PDT) From: Felipe Contreras To: notmuch@notmuchmail.org Subject: [PATCH 01/13] test: fix passwd_sanitize() Date: Sat, 1 May 2021 06:54:10 -0500 Message-Id: <20210501115422.483314-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20210501115422.483314-1-felipe.contreras@gmail.com> References: <20210501115422.483314-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Message-ID-Hash: UQUPT5CWK35BPXTNLCQ5MLU3QATFA2EC X-Message-ID-Hash: UQUPT5CWK35BPXTNLCQ5MLU3QATFA2EC X-MailFrom: felipe.contreras@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Daniel Kahn Gillmor X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1619870095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=g0Yth9IzAHsQT9EBxPTfcn3qHsrWuMB9uOoTkNap36Q=; b=BdNhAG5KEpy/JvIXe0O4JxpxhLk228ED0wNYjVNKySxQrLXxyWRR+cYzBEXjHHX74MqhZ5 ZoUUEkHJCUNCZLACoa7Qz+Fh0IFVr15eG/vhsakIwGbKJNhuN7hr3KOyESU1hPQ02FQIm7 hcVmdw7HmKlnM2gylDQsnsDsEdTDQyGfcAUWlVegZNx2uU/49roYf7KptJUM24SsbgWXD3 pSVv8g+v+E2feOoQmYIbKgU6rtPPMpWI7MaWGT0lqAvVkb+LR4+tbCEzjE9LlMixZHY5QS tzqbPzl0bUBFICCFLwzsYf4kXSEAcghf2u4Y3iSHMZqfAjSu/KYdTgwtXaaIbw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1619870095; a=rsa-sha256; cv=none; b=s2jW8CHyz0/qSenxsgxp9WFftpzV57UXMlUz7ybjeqy0PNn2e3jdkADpnRO4XjeE2Ih5GR hYZcNrTtyZ4kCARv0C2yw1cbpt67rn1KGSF2VPEjeIfI+Yyh5zBDojI4SsO/ILMRFUkIQe +CXN/oTuXsRWo/o3QHK9+AjNs3q3pWzOdZr1rYR+PGRJPrVnxosvs2kF0CVls7+Ga3C9bd nTd98uaB5rQ88AudIHBklFs1I3t0DESrSVDkpEVDzNmIPhIum2Hx6QmR3LBRIWiJzr3Abw 05eBopOaPpHz4MFNwfAgZG1Kk3SNitzG2CmYunWonyFGY8lAEWge/llAdd1k3Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=fEF7lBZH; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.00 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20161025 header.b=fEF7lBZH; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 3543E1A4F1 X-Spam-Score: -1.00 X-Migadu-Scanner: scn0.migadu.com X-TUID: 3QJ6JYp56w4b 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 --- test/test-lib.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/test-lib.sh b/test/test-lib.sh index 4c9f2a21..e13797a7 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -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) ' } -- 2.31.0