From nobody Sun Dec 22 05:20:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=patchew-devel-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=bytedance.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1644921387305975.8621624243804; Tue, 15 Feb 2022 02:36:27 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-GJ7awPiPOvOoWSGFDhDAkw-1; Tue, 15 Feb 2022 05:36:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0845D1006AA0; Tue, 15 Feb 2022 10:36:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 000926FB87; Tue, 15 Feb 2022 10:36:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id ECC594BB7C; Tue, 15 Feb 2022 10:36:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21FAaJnY013020 for ; Tue, 15 Feb 2022 05:36:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 99BC7407DEC5; Tue, 15 Feb 2022 10:36:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 952A5407DEC3 for ; Tue, 15 Feb 2022 10:36:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7330B802319 for ; Tue, 15 Feb 2022 10:36:19 +0000 (UTC) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-pHBPydIUP0iSjuJV6Qo51w-1; Tue, 15 Feb 2022 05:36:17 -0500 Received: by mail-wm1-f45.google.com with SMTP id v129so11094253wme.2 for ; Tue, 15 Feb 2022 02:36:16 -0800 (PST) Received: from localhost ([46.69.19.210]) by smtp.gmail.com with ESMTPSA id b2sm8301379wri.35.2022.02.15.02.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 02:36:15 -0800 (PST) X-MC-Unique: GJ7awPiPOvOoWSGFDhDAkw-1 X-MC-Unique: pHBPydIUP0iSjuJV6Qo51w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=51Gz8ZvRNAVJaI3GkhOPqrEDASFgOTiqAcNzY91l3iU=; b=xW21MGVRC29O2SLfRsv8gf3NZumtBn/5sw96TnR32uEdYvy7m3BU7YhiSyYrr++fHI zEXMwk/kuWO6eq+gcEffwwj4/Fa0s4pvl66ReqmMIk1HIZvjStC4b28vjDd7Jwdi07R5 DODKpWEYlu3+Q7LkrT4aVcseikNrWov4/MxnIUcpe+mzDoZMexXfYotKAV4VPYEeKmkV SNJN/+8DCRvHDakSO1UfQQlwyDL/0ntIhQIrWeYl24nErmVNIOJGD+gd4jG2NPxDjK/f IHIsI60EHAqRd6m1TbUUO9Sebrq4z+PvS3hSG7CK0436knWAUFtMCWwtMBpM61wHueFI tAGA== X-Gm-Message-State: AOAM533TnWzjjoZvqqZgwhpgnb1QLf3oXrpEnm2w/TkTscDLRPQdYflm J8P/l9YxTn6L7MhLquD49P8JveCWNLR+pQ== X-Google-Smtp-Source: ABdhPJwvVnyobnbYvimOBpcnZIZUezMysrifK472XMJYzWqBUOeKv4mx+Z4HYyUQgA5eiUC2uW7jDA== X-Received: by 2002:a05:600c:384c:b0:37b:c771:499c with SMTP id s12-20020a05600c384c00b0037bc771499cmr2423668wmr.141.1644921375766; Tue, 15 Feb 2022 02:36:15 -0800 (PST) From: Fam Zheng To: patchew-devel@redhat.com Date: Tue, 15 Feb 2022 10:36:14 +0000 Message-Id: <20220215103614.3002033-1-fam.zheng@bytedance.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-loop: patchew-devel@redhat.com Cc: Fam Zheng , Mat Martineau Subject: [Patchew-devel] [PATCH] import: Fix mailing list matching X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=patchew-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1644921388360100001 Content-Type: text/plain; charset="utf-8" If the mbox has no To: field, we have an empty addr in the returned address list. This is later used in Project.recognizes() as: if addr in self.mailing_list: ... Remove the empty result. Also preprocess the mailing_list before matching. Reported-by: Mat Martineau Signed-off-by: Fam Zheng Reviewed-by: Paolo Bonzini --- api/models.py | 6 +++++- mbox.py | 2 ++ tests/data/0036-patch-with-no-to-header.mbox.gz | Bin 0 -> 4783 bytes tests/test_import.py | 11 +++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/data/0036-patch-with-no-to-header.mbox.gz diff --git a/api/models.py b/api/models.py index 5879466..18392b1 100644 --- a/api/models.py +++ b/api/models.py @@ -265,11 +265,15 @@ class Project(models.Model): return True return False =20 + def get_mailing_lists(self): + r =3D self.mailing_list.split() + return [x.rstrip(',;') for x in r] + def recognizes(self, m): """Test if @m is considered a message in this project""" addr_ok =3D False for name, addr in m.get_to() + m.get_cc(): - if addr in self.mailing_list: + if addr in self.get_mailing_lists(): addr_ok =3D True break if addr_ok: diff --git a/mbox.py b/mbox.py index 20abca1..bcd3600 100644 --- a/mbox.py +++ b/mbox.py @@ -115,6 +115,8 @@ class MboxMessage(object): addrs =3D email.utils.getaddresses(f) for name, addr in addrs: name =3D name or addr + if not addr: + continue if text: ret.append(_addr_fmt_text(name, addr)) else: diff --git a/tests/data/0036-patch-with-no-to-header.mbox.gz b/tests/data/0= 036-patch-with-no-to-header.mbox.gz new file mode 100644 index 0000000000000000000000000000000000000000..32a33915a9317151845bec80e33= 49b7de8064ac5 GIT binary patch literal 4783 zcmV;g5>V|Qiw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