From patchwork Sun Nov 4 14:06:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 992745 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42nyKB1CrSzB6MZ for ; Mon, 5 Nov 2018 01:06:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="ECta998e"; 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 42nyK92K6kzDrhR for ; Mon, 5 Nov 2018 01:06:21 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="ECta998e"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=that.guru (client-ip=159.100.240.208; helo=relay-ext2.mxrelay.co; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=that.guru Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" (0-bit key; unprotected) header.d=that.guru header.i=@that.guru header.b="ECta998e"; dkim-atps=neutral Received: from relay-ext2.mxrelay.co (relay-ext2.mxrelay.co [159.100.240.208]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42nyK51QF5zDrPy for ; Mon, 5 Nov 2018 01:06:17 +1100 (AEDT) Received: from filter001.mxrelay.co (filter001.mxrelay.co [64.52.23.203]) by relay-ext2.mxrelay.co (Postfix) with ESMTP id 4384D3FC4F for ; Sun, 4 Nov 2018 14:06:12 +0000 (UTC) Received: from one.mxroute.com (one.mxroute.com [195.201.59.211]) by filter001.mxrelay.co (Postfix) with ESMTPS id 6DD78100AEA for ; Sun, 4 Nov 2018 14:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=bmLVootgi7mTPM1pkgBDA2QCegC+nzi+/mMdJE8XGzI=; b=ECta998eKuKLtqGBUtZEnn52ea fCQtyqjeOHwxaWmdH3AUU+XhAjKYDHbhCk/MWzZmn8FDICkrF3e72k24RhuC3Mic76TPCZ/BUcxWw zzGCkT+2zUN6DInPl1yNnSUkpaSZ9T0O/U+Ml8jz64TX/GHzgmmtOX8ydKCWL42KrTuw7ZPfCiSSR i1XkApLfDIBK7OEigpPCpefUpqPAGmt67DUJhKteplxBIiYCvnueG/JgAkO2J4yu8qQ8696W3mWzd fbj48zpWtzHTq/vMP0UGgi2q/d7N+H7fLN3qv/eJM4a+yT/YZ6x2YbtcgRkY8xdjQvqXIRRb3qv8O kp5/j1AA==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [PATCH] parser: Ensure whitespace is stripped for long headers Date: Sun, 4 Nov 2018 14:06:03 +0000 Message-Id: <20181104140603.29412-1-stephen@that.guru> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-AuthUser: stephen@that.guru 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: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" RFC2822 states that long headers can be wrapped using CRLF followed by WSP [1]. For example: Subject: Foo bar, baz Should be parsed as: Foo bar,baz While we were stripping the former, we were not stripping the latter. This mean that we ended up with the following: Foo bar, baz Resolve this. Signed-off-by: Stephen Finucane Closes: #197 --- patchwork/parser.py | 1 + patchwork/tests/test_parser.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/patchwork/parser.py b/patchwork/parser.py index d6fa8437..946b6685 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -47,6 +47,7 @@ class DuplicateMailError(Exception): def normalise_space(value): + value = ''.join(re.split(r'\n\s+', value)) whitespace_re = re.compile(r'\s+') return whitespace_re.sub(' ', value).strip() diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py index a9df5e35..664edd5b 100644 --- a/patchwork/tests/test_parser.py +++ b/patchwork/tests/test_parser.py @@ -832,6 +832,8 @@ class SubjectTest(TestCase): self.assertEqual(clean_subject('[PATCH] meep'), ('meep', [])) self.assertEqual(clean_subject("[PATCH] meep \n meep"), ('meep meep', [])) + self.assertEqual(clean_subject("[PATCH] meep,\n meep"), + ('meep,meep', [])) self.assertEqual(clean_subject('[PATCH RFC] meep'), ('[RFC] meep', ['RFC'])) self.assertEqual(clean_subject('[PATCH,RFC] meep'),