From patchwork Tue Jan 8 12:38:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ali Alnubani X-Patchwork-Id: 1021884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43YsNH6W6sz9sDL for ; Tue, 8 Jan 2019 23:42:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="HwVTAU3v"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 43YsNH59N9zDqW1 for ; Tue, 8 Jan 2019 23:42:23 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=2a01:111:f400:fe1f::601; helo=eur01-ve1-obe.outbound.protection.outlook.com; envelope-from=alialnu@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="HwVTAU3v"; dkim-atps=neutral Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0601.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1f::601]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 43YsJH6bt3zDqSF for ; Tue, 8 Jan 2019 23:38:55 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JoE/jhf6QSEz27qDt1hXxeykDmd+vKLvTdhLcHAxsfM=; b=HwVTAU3vzPwRyYdNwOOZW8RuFyBkR8FQThqMU0nSiGNQmEk0cb6SF0x4LNrZGodlyQbj3WRiPzOJcVK7VXb/jegSFnZzzBbeMss0vRsuc8hiCd5vBONrEIkDGV7spysW5AICICQ5f2JALh0Z6pQzVkW1U3EROsS8CCCfGMh0IIQ= Received: from VI1PR05MB4269.eurprd05.prod.outlook.com (52.133.12.22) by VI1PR05MB6272.eurprd05.prod.outlook.com (20.177.49.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1516.13; Tue, 8 Jan 2019 12:38:48 +0000 Received: from VI1PR05MB4269.eurprd05.prod.outlook.com ([fe80::39c0:bdf5:cba0:8f14]) by VI1PR05MB4269.eurprd05.prod.outlook.com ([fe80::39c0:bdf5:cba0:8f14%5]) with mapi id 15.20.1495.011; Tue, 8 Jan 2019 12:38:48 +0000 From: Ali Alnubani To: "patchwork@lists.ozlabs.org" Subject: [PATCH] Add setting to specify subject prefixes to ignore Thread-Topic: [PATCH] Add setting to specify subject prefixes to ignore Thread-Index: AQHUp08ZRi5YXV9jeUWZORfesushHA== Date: Tue, 8 Jan 2019 12:38:48 +0000 Message-ID: <20190108123834.2225-8-alialnu@mellanox.com> References: <20190108123834.2225-1-alialnu@mellanox.com> In-Reply-To: <20190108123834.2225-1-alialnu@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.11.0 x-clientproxiedby: LO2P265CA0316.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a4::16) To VI1PR05MB4269.eurprd05.prod.outlook.com (2603:10a6:803:40::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=alialnu@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2001:4b98:dc0:51:216:3eff:feac:53b] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR05MB6272; 6:ljvR6rngdmr8gQClxieTcTp/Sk36NEsyfIBDfBMnQbuSEKvf2Rlr/SJ1zEJObLfBF8zvo862JFM+McT6CHiaTlj5CK7bnhpaoiI/k6jhgRP5q7nG1r3AnpUWaQXg7iNc3wDsYGILZ1Lp6ABV0w6HWpwzWkPpsksNCRVIRQz+1+lSf9h0Vw+l7clj7sKyZLFy2UW4iHWRzpEa8/zBAC940RLUE2Da50W4b8VVJ0wOfbQRkFQkS19yWsW+bQGDipJHFML2rhQQDUIfOIX6ZQR56a8/thO4TCfCuSmkbLNLOsN9udWQVxACHqVdVi+YnrwysF9E4icP+WZbRmoIEwolIQY3LGl6PHB+0m0nci+7TmR8iaVSnVFYFPUhMUr8WlWviFdlf+c9aE0lBDZN1DowC98YwhsoWAWqNiWg+/BKH0vg+yMQ8A3lOLJ0BX7OHpn+hAGVs5CvH5fbEUL058NfQg==; 5:Ed5QePScQ0rSrMC37D4HC97JU/i90rCWlmXmHjpMPbfXk3Ttr5a/AbUlRr7p7+4QRUePTrOc/4R0zt2UqlbKlzE/o2vYm2ljVb3KD802QM1PGHIBwrvwplbartziTA1+gho5Bf2AjIoVlZdV30349toMv67JaD/oTh1mTs/sYahbCBgIjRPUhBXtf9k7JaJgt1wlXuu5hdzNF6QecZ0hsA==; 7:nG5FLViNoBlD8tm6pFfQRQsI4+TjEhi7/Uoti+kLSY3Mfgu1qwoepFX0jZFAi+LS2qn6Ea8W4j8knTLS/uZ+TObkE8TTsZJwg4IVPshlKNvODgFArfqQG0PRinhJHyOwWSCV6oO2qeR9SIa0D6YJWA== x-ms-office365-filtering-correlation-id: fdac0fe8-b060-4746-a4c4-08d675663c51 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600109)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB6272; x-ms-traffictypediagnostic: VI1PR05MB6272: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(908002)(999002)(5005026)(6040522)(8220060)(2401047)(8121501046)(3002001)(3231475)(944501520)(4982022)(52105112)(93006095)(93001095)(10201501046)(6055026)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:VI1PR05MB6272; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB6272; x-forefront-prvs: 0911D5CE78 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(136003)(376002)(39860400002)(366004)(346002)(189003)(199004)(316002)(2616005)(446003)(11346002)(46003)(476003)(2501003)(81156014)(81166006)(6306002)(8936002)(6512007)(4326008)(25786009)(305945005)(256004)(6116002)(97736004)(7736002)(14444005)(486006)(386003)(6506007)(2351001)(105586002)(52116002)(102836004)(106356001)(76176011)(6916009)(186003)(71200400001)(478600001)(36756003)(966005)(68736007)(71190400001)(99286004)(1076003)(2906002)(6486002)(5660300001)(53936002)(8676002)(86362001)(50226002)(1730700003)(5640700003)(14454004)(6436002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB6272; H:VI1PR05MB4269.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: ul27io+wndGeFo82hu0vi7gsWPJO4Crm+54SgbIwgonBQvlbtxkPoI8Yp/Jklx+ugZMIruwFbJE6Jr99qpCxq7BxB45fWLh+NPnINU2mdJax/XsPbFPz7u0H6+1atotO3aDP/Kk2UJhCqiQcCnYNjKcM8m+jdSU2iTjJffVlEL605lEuNMdLR90uHucCx1IP3z7iiDN5mjGpFBPltrPhwqDOduPvuQ1z/QV/SAcy+X+99BdtGZwWBsvJr0EU8ZHDb23KeTHaLTLcKTmQ/yGEWXvsHGc3N6fGeDhp7qRDArh5aYsjFkSlhouHRSAw/oha spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: fdac0fe8-b060-4746-a4c4-08d675663c51 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jan 2019 12:38:47.7240 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB6272 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Monjalon Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" The only prefix that was being ignored was the project.linkname. This patch adds the new setting: `SUBJECT_PREFIXES_TO_IGNORE`, which can be a list of strings to be removed from the subject by the parser. Suggested-by: Thomas Monjalon Signed-off-by: Ali Alnubani --- docs/deployment/configuration.rst | 7 +++++++ patchwork/parser.py | 9 +++++++-- patchwork/settings/base.py | 3 +++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/deployment/configuration.rst b/docs/deployment/configuration.rst index 0601276..4f718e9 100644 --- a/docs/deployment/configuration.rst +++ b/docs/deployment/configuration.rst @@ -112,5 +112,12 @@ Force use of ``https://`` links instead of guessing the scheme based on current access. This is useful if SSL protocol is terminated upstream of the server (e.g. at the load balancer) +``SUBJECT_PREFIXES_TO_IGNORE`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Case-insensitive prefixes to remove from patch subjects. + +.. versionadded:: 2.2 + __ https://docs.djangoproject.com/en/1.8/ref/settings/ __ http://www.django-rest-framework.org/api-guide/settings/ diff --git a/patchwork/parser.py b/patchwork/parser.py index c7297ae..b508616 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -14,6 +14,7 @@ from fnmatch import fnmatch import logging import re +from django.conf import settings from django.contrib.auth.models import User from django.db.utils import IntegrityError from django.utils import six @@ -37,6 +38,8 @@ list_id_headers = ['List-ID', 'X-Mailing-List', 'X-list'] SERIES_DELAY_INTERVAL = 10 +SUBJECT_PREFIXES_TO_IGNORE = settings.SUBJECT_PREFIXES_TO_IGNORE + logger = logging.getLogger(__name__) @@ -278,7 +281,8 @@ def _find_series_by_markers(project, mail, author): """ subject = mail.get('Subject') - name, prefixes = clean_subject(subject, [project.linkname]) + SUBJECT_PREFIXES_TO_IGNORE.append(project.linkname) + name, prefixes = clean_subject(subject, SUBJECT_PREFIXES_TO_IGNORE) _, total = parse_series_marker(prefixes) version = parse_version(name, prefixes) @@ -973,7 +977,8 @@ def parse_mail(mail, list_id=None): msgid = msgid[:255] subject = mail.get('Subject') - name, prefixes = clean_subject(subject, [project.linkname]) + SUBJECT_PREFIXES_TO_IGNORE.append(project.linkname) + name, prefixes = clean_subject(subject, SUBJECT_PREFIXES_TO_IGNORE) is_comment = subject_check(subject) x, n = parse_series_marker(prefixes) version = parse_version(name, prefixes) diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py index 15644b4..f5b3ab8 100644 --- a/patchwork/settings/base.py +++ b/patchwork/settings/base.py @@ -227,3 +227,6 @@ COMPAT_REDIR = True # the scheme based on current access. This is useful if SSL protocol # is terminated upstream of the server (e.g. at the load balancer) FORCE_HTTPS_LINKS = False + +# Case-insensitive prefixes to remove from patch subjects +SUBJECT_PREFIXES_TO_IGNORE=[]