From patchwork Wed Jun 20 12:21:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuri Volchkov X-Patchwork-Id: 932168 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 419kVK28xXz9s4w for ; Wed, 20 Jun 2018 22:22:17 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jtU271Fj"; 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 419kVJ6f7QzF0ph for ; Wed, 20 Jun 2018 22:22:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jtU271Fj"; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=yuri.volchkov@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="jtU271Fj"; dkim-atps=neutral Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 419kV24Gk1zF0l6 for ; Wed, 20 Jun 2018 22:21:58 +1000 (AEST) Received: by mail-wm0-x241.google.com with SMTP id n5-v6so6480902wmc.5 for ; Wed, 20 Jun 2018 05:21:58 -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; bh=TOHSAvxNLx4ChmuQidNtcfaN3kd/U8/StWE1dnrnG0k=; b=jtU271FjOUNbt9LOH9tiRxhcR2xv2c1XfEimJYGNAuqymmLfqutdlVFkp+8b9BQQ/m isBAHhbSUTmrtDTDfWoOvJDcsMA33w+XGcmX3mzzrqlr1xs2H/Zth+J2bbcWOq5uAjkr VqCoiY/HIXOYve08yiq3jXILqb8Pbe1erZxUulInOV2o6fdkVQjUIoSFJvuJA2QwU4bE adS0i6+L09i4n1Av+ZajG83+ATEKCAaSjAThJL4lV95T48Ylgy+nLTtWd9EOFWtCqtAd eLX8Jmv9x0OgQCTqhZ+BPZgx5Dc6upQFbxlHo7cN4uLrAIJUaPF0lgUP2qDZ7G7kTkV6 oUOQ== 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; bh=TOHSAvxNLx4ChmuQidNtcfaN3kd/U8/StWE1dnrnG0k=; b=IdjNe2xmrLvTXKb+kDVS5V+g4H9UxTx89OakbP1eNdigUrHodRVR+aJQL0F4SYhElb fR6BIPGZ984j+iFNmvznXYnh6+N6ypKJX+QAuMo6aMS+hyVCBrUsJpZ+ZQqYY4LiUxcZ wNgfQbtgDukHt4507xhfHjpxSKHhLraZc1PQP5b/ywuB9sag+JIGJqr7C3JVN70FsobI uQrfYvk9khPUVR+BYSY4hYimWztPILRx397f3wIxO6JXO3IfgJ6qu+1oD2wHqRGHUinf A1gsmWXn5Eh60O0d94iBXiNjXKsCz0tl5zam6QcZ1Dt0bENs4wkF0/5ceKDQOLOYi4aN i46Q== X-Gm-Message-State: APt69E3heOL1swwJU/BWYdahILW5uoBVpDLJQhlBb8GPy6movnRpCQ4x tbDmbTw9XivSXBxuGS5XVnuihyCd X-Google-Smtp-Source: ADUXVKKwBQwPBhnWqdFf70Xx6EMvIDWvK7G10XKZQWqO88AmNV4+2pg/mtDphxdO9x/dyXb4QKFTbg== X-Received: by 2002:a1c:2348:: with SMTP id j69-v6mr1627015wmj.112.1529497314327; Wed, 20 Jun 2018 05:21:54 -0700 (PDT) Received: from localhost (mito.neclab.eu. [195.37.70.39]) by smtp.gmail.com with ESMTPSA id d3-v6sm2041236wrr.90.2018.06.20.05.21.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 05:21:53 -0700 (PDT) From: Yuri Volchkov To: patchwork@lists.ozlabs.org Subject: [PATCH] parsemail: ignore html part of multi-part comments Date: Wed, 20 Jun 2018 14:21:42 +0200 Message-Id: <20180620122142.9917-1-yuri.volchkov@gmail.com> X-Mailer: git-send-email 2.17.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.26 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" Currently an html-protection present only for patch-emails. If a multi-part comment-email arrives, it messes up patchwork. In my case, the symptom was a non intended 'Signed-off-by' in the downloaded patches, with html-like junk. This patch makes parsemail skip all parts of comment which are not text/plain. Of course, this will drop html-only emails completely. But they can not be parsed anyways. Signed-off-by: Yuri Volchkov --- patchwork/parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/patchwork/parser.py b/patchwork/parser.py index 8f9af81..b1fb7b9 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -576,9 +576,11 @@ def find_comment_content(mail): """Extract content from a mail.""" commentbuf = '' - for payload, _ in _find_content(mail): + for payload, subtype in _find_content(mail): if not payload: continue + if subtype != 'plain': + continue commentbuf += payload.strip() + '\n'