From patchwork Sat Jan 14 11:17:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 136093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 77C72B701C for ; Sun, 15 Jan 2012 05:32:26 +1100 (EST) Received: from e06smtp16.uk.ibm.com (e06smtp16.uk.ibm.com [195.75.94.112]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e06smtp16.uk.ibm.com", Issuer "GeoTrust SSL CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id BC163B6F62 for ; Sat, 14 Jan 2012 22:19:24 +1100 (EST) Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 14 Jan 2012 11:19:18 -0000 Received: from d06nrmr1407.portsmouth.uk.ibm.com ([9.149.38.185]) by e06smtp16.uk.ibm.com ([192.168.101.146]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 14 Jan 2012 11:19:15 -0000 Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by d06nrmr1407.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0EBJEY92326700 for ; Sat, 14 Jan 2012 11:19:14 GMT Received: from d06av11.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0EBJEb5015758 for ; Sat, 14 Jan 2012 04:19:14 -0700 Received: from localhost (sig-9-145-169-236.de.ibm.com [9.145.169.236]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q0EBJDpq015755; Sat, 14 Jan 2012 04:19:14 -0700 From: Stefan Hajnoczi To: patchwork@lists.ozlabs.org Subject: [PATCH] parser: allow words starting with "diff" at beginning of line Date: Sat, 14 Jan 2012 11:17:40 +0000 Message-Id: <1326539860-5023-1-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.7.3 x-cbid: 12011411-3548-0000-0000-000000B246DB X-Mailman-Approved-At: Sun, 15 Jan 2012 05:32:24 +1100 Cc: Stefan Hajnoczi X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org The patch parser splits emails incorrectly when the comment contains a line whose first word starts with "diff" (like "difficult" or "different"). For a real-life example of an email that triggers this bug, see http://patchwork.ozlabs.org/patch/135291/. Fix the issue by checking for a space after "diff". Add DiffWordInCommentTest to the test suite. Signed-off-by: Stefan Hajnoczi --- apps/patchwork/parser.py | 2 +- apps/patchwork/tests/patchparser.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/apps/patchwork/parser.py b/apps/patchwork/parser.py index 2b5e9a0..f460566 100644 --- a/apps/patchwork/parser.py +++ b/apps/patchwork/parser.py @@ -68,7 +68,7 @@ def parse_patch(text): line += '\n' if state == 0: - if line.startswith('diff') or line.startswith('===') \ + if line.startswith('diff ') or line.startswith('===') \ or line.startswith('Index: '): state = 1 buf += line diff --git a/apps/patchwork/tests/patchparser.py b/apps/patchwork/tests/patchparser.py index 3870dc8..06b4e54 100644 --- a/apps/patchwork/tests/patchparser.py +++ b/apps/patchwork/tests/patchparser.py @@ -121,6 +121,11 @@ class ListFooterTest(InlinePatchTest): (self.patch, self.comment) = find_content(self.project, email) +class DiffWordInCommentTest(InlinePatchTest): + test_comment = 'Lines can start with words beginning in "diff"\n' + \ + 'difficult\nDifferent' + + class UpdateCommentTest(InlinePatchTest): """ Test for '---\nUpdate: v2' style comments to patches. """ patch_filename = '0001-add-line.patch'