From nobody Thu Apr 25 04:21:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1543308593708854.0860447827605; Tue, 27 Nov 2018 00:49:53 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5FE553086267; Tue, 27 Nov 2018 08:49:52 +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 5156860C47; Tue, 27 Nov 2018 08:49:52 +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 436DB3F953; Tue, 27 Nov 2018 08:49:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAR8np9G010725 for ; Tue, 27 Nov 2018 03:49:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id B8DE25DAA0; Tue, 27 Nov 2018 08:49:51 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B74DA5DD63; Tue, 27 Nov 2018 08:49:45 +0000 (UTC) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8CD8C3078AA7; Tue, 27 Nov 2018 08:49:43 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id j2so21771452wrw.1; Tue, 27 Nov 2018 00:49:43 -0800 (PST) Received: from localhost.localdomain ([2001:b07:6468:f312:60a1:384e:4c17:72ad]) by smtp.gmail.com with ESMTPSA id y34sm5083010wrd.68.2018.11.27.00.49.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 00:49:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ua1AtJxJDRCF3uJdRlvudHpy50kqJfwNljEdFtJ4Xh0=; b=cXA5eC3oXW5HrvmRci5UwyYoujKAVNGL50mTYiB1ABxwVkvGj5VxyyrNsMqvhKo3Ny Lyf1fuBz3oY/cu1ecs7+T4dvNFtVQifArxZc6uyiyktSzb9bJn1L+vGlOv4NQ/smrg21 LlmZXebMBQOnGAS0INDhcF9FNMejccjiC1paW0TMLQQD/kNxvLxJ2eusrvw4QjitMIeF q93KHei4Vi2z01TXvCrwTU+RMqyY4CigPthMOLM9whwlPCTXI33wbb32rt8a9ookY6YW EFe+LUUfyGYq8w+onmVigkvtoL+xrxTZQff8K72+z7TkU7aMWFbm6x7NCgerNzbX8mHj vPtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ua1AtJxJDRCF3uJdRlvudHpy50kqJfwNljEdFtJ4Xh0=; b=WC5LwWbnGMgczjg90G5Uv3v0uwsffGQ3jcAJ2Qa+MRxjfCnVLugWPyispuqQO0s2Zd OdFDFO19YTV9O+/1L+G1nQN30bFhuGoIeblPLjhCfmQFXGVbBuGXw+gF2rqAXVJUDBuk SlgMWvdiuUTrt85mfQJ/vlJsQyRdAgPD2toAaYXgTIvmUTPDEDz5Opm5YMb3io2Bj0lr XGBrSQvTfaW+tvUJvTMDfWPf2vjkuW5SXxHDyb14U0WfyPw42dSWWqQ0MkETx7l32Dv5 NlZ3emKRHRrRcM4BmIL2XGtEUfIAXrNHipjhxjOeOYWUhtlROf1rjWW3bGvIstmIrXrb ClJA== X-Gm-Message-State: AA+aEWbnUVsb1BKBtjA++XjYlM0n9uSrIgJd8F0JZK+N/X6jiHK6+G0M qLWRJntxHD6qFX4LO5W6Vm7d6gNY X-Google-Smtp-Source: AFSGD/WspFC6F+DTWcayG/WvzOveIlT63T/ktnpyF5HGm/BdKH24TCMESjN6nbBmN5S7WgIxEqa//Q== X-Received: by 2002:a5d:43d0:: with SMTP id v16mr28378078wrr.67.1543308581896; Tue, 27 Nov 2018 00:49:41 -0800 (PST) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Tue, 27 Nov 2018 09:49:34 +0100 Message-Id: <20181127084935.17898-2-pbonzini@redhat.com> In-Reply-To: <20181127084935.17898-1-pbonzini@redhat.com> References: <20181127084935.17898-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 27 Nov 2018 08:49:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 27 Nov 2018 08:49:43 +0000 (UTC) for IP:'209.85.221.47' DOMAIN:'mail-wr1-f47.google.com' HELO:'mail-wr1-f47.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.24 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.221.47 mail-wr1-f47.google.com 209.85.221.47 mail-wr1-f47.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: patchew-devel@redhat.com Cc: famz@redhat.com Subject: [Patchew-devel] [PATCH 1/2] views: join messages as bytes into the mbox 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: , Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 27 Nov 2018 08:49:52 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" To simplify the code, let email.message do the encoding and create the From= line for the mbox. The case where a message cannot be parsed is not handled any= more; it was not necessary because that should have resulted in a failed import in the first place. Signed-off-by: Paolo Bonzini Reviewed-by: Caio Carrara --- www/views.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/www/views.py b/www/views.py index 49357e2..45f63c8 100644 --- a/www/views.py +++ b/www/views.py @@ -286,17 +286,14 @@ def view_mbox(request, project, message_id): =20 def get_mbox_with_tags(m): mbox =3D m.get_mbox() - try: - msg =3D email.message_from_string(mbox) - except Exception: - return mbox + msg =3D email.message_from_string(mbox) container =3D msg.get_payload(0) if msg.is_multipart() else msg if container.get_content_type() !=3D "text/plain": - return mbox + return msg.as_bytes(unixfrom=3DTrue) =20 payload =3D decode_payload(container) container.set_payload('\n'.join(mbox_with_tags_iter(payload, m.tag= s))) - return msg.as_string() + return msg.as_bytes(unixfrom=3DTrue) =20 s =3D api.models.Message.objects.find_message(message_id, project) if not s: @@ -310,14 +307,8 @@ def view_mbox(request, project, message_id): =20 mbox_list =3D [] for message in messages: - mbox_list.append( - "From %s %s\n%s" % ( - message.get_sender_addr(), - message.get_asctime(), - get_mbox_with_tags(message) - ) - ) - mbox =3D "\n".join(mbox_list) + mbox_list.append(get_mbox_with_tags(message)) + mbox =3D b"\n".join(mbox_list) return HttpResponse(mbox, content_type=3D"text/plain") =20 =20 --=20 2.19.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel From nobody Thu Apr 25 04:21:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1543308595911667.9956792410844; Tue, 27 Nov 2018 00:49:55 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 94661307DAC1; Tue, 27 Nov 2018 08:49:54 +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 84D5D5C26E; Tue, 27 Nov 2018 08:49:54 +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 7866F3F953; Tue, 27 Nov 2018 08:49:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAR8nr9w010735 for ; Tue, 27 Nov 2018 03:49:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id BC7501001F5E; Tue, 27 Nov 2018 08:49:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CBCA105B1E0; Tue, 27 Nov 2018 08:49:47 +0000 (UTC) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 09CE39B307; Tue, 27 Nov 2018 08:49:45 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id r10so21729182wrs.10; Tue, 27 Nov 2018 00:49:44 -0800 (PST) Received: from localhost.localdomain ([2001:b07:6468:f312:60a1:384e:4c17:72ad]) by smtp.gmail.com with ESMTPSA id y34sm5083010wrd.68.2018.11.27.00.49.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Nov 2018 00:49:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F3wki+Eg21nq2XmqDurPmbvjpylp+h+ZUhZ+wvTLb/0=; b=qx3zr8wJ4MWMr6nxXBy+zuSVeGpJZdAowL3ipgEp3QkElw4CaWv/OS/qc5Gq1E9+ai FXb5aGlZo4/FyhQApP6c8NpRAp9g/i1kI4egSLg3L/wrjQvZKGdDy9qO9wTFzO7kZa2q +gNjPLRTrf4mP53eDV9BehjUrhVDyY2guKzICYWDe/0Emkrosh2w5Jq6qGWuL9wfe+f7 0HvdE1AZAma7pHf5f8gqUbR7eYqi8SdeFV1M2S1dkhgoLTKEpa43rUgmq28SGF+kz9oQ gqHdt/m6BQmNk6WrK7IygwMpfi7V4SFaVQVbLKX2Ool5TW6wJda7IB3CSWXMnEUceHdb nLwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=F3wki+Eg21nq2XmqDurPmbvjpylp+h+ZUhZ+wvTLb/0=; b=XK1xA8k6jSiwWa6Fi8chzy5szkqAQ+fDh5XMo9dTR/G9CE1/DxNld3OgwKol1U+W45 C5pBAKO/vkIRrOzJaxlTz+2XqxoqgjNgoPoTecoXvfpib3k2QR3Hi5hnd6hl4HZqAf+Y 2BYND9zU36LgqlPLDGBu7hVi6TeFPG4yW5mRyAJvMdVpO8AG0eZabG8aPTOWwNn7qD/3 qrrKNog48rfsILggu3qAIVteg5UtFc0IQOpPdBS3UMWCLy4M9ZcRzS6aBQala5pbgkOf 4wjutrafdNzJ8fBv/QAcUcxJ+6SAFwUPWEqFBzcI1jY68/sCgnhYl70l/iOkAAzzB19j 9Ceg== X-Gm-Message-State: AA+aEWa+VCqULqY5QW591aiLUAfmUsa1f/e86Nd16oUQ7FmFzMQzaKW9 iEIeR5PoURGDb2InYtAujvt5fiUk X-Google-Smtp-Source: AFSGD/W9aXVf+qQsAfo99m+4X0vewJqZt5aXihmis5x4SsACTb/U+GN1PiFAj5ur0M4R0dtiVCXtxg== X-Received: by 2002:a5d:4286:: with SMTP id k6mr26747865wrq.225.1543308583140; Tue, 27 Nov 2018 00:49:43 -0800 (PST) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Tue, 27 Nov 2018 09:49:35 +0100 Message-Id: <20181127084935.17898-3-pbonzini@redhat.com> In-Reply-To: <20181127084935.17898-1-pbonzini@redhat.com> References: <20181127084935.17898-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 27 Nov 2018 08:49:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 27 Nov 2018 08:49:45 +0000 (UTC) for IP:'209.85.221.51' DOMAIN:'mail-wr1-f51.google.com' HELO:'mail-wr1-f51.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.24 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.221.51 mail-wr1-f51.google.com 209.85.221.51 mail-wr1-f51.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: patchew-devel@redhat.com Cc: famz@redhat.com Subject: [Patchew-devel] [PATCH 2/2] views: fix Content-Transfer-Encoding and Content-Type of downloaded mbox 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 27 Nov 2018 08:49:54 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) set_payload expects the argument to be already encoded according to the message's content type and transfer encoding. Force a good charset and transfer encoding, in case the source message's is incompatible with the trailers. Otherwise, if the source message specified for example an iso-8859-1 encoding, we get mojibake in the utf-8 trailers. Otherwise, adding an 8-bit trailer to a 7-bit message causes the email module to switch to quoted-printable, without the body actually being quoted-printable. As a result, all equals sign in the original message are broken. Signed-off-by: Paolo Bonzini Reviewed-by: Caio Carrara --- tests/data/0028-tags-need-8bit-encoding.mbox.gz | Bin 0 -> 6585 bytes tests/test_tags.py | 13 +++++++++++++ www/views.py | 11 ++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/data/0028-tags-need-8bit-encoding.mbox.gz diff --git a/tests/data/0028-tags-need-8bit-encoding.mbox.gz b/tests/data/0= 028-tags-need-8bit-encoding.mbox.gz new file mode 100644 index 0000000000000000000000000000000000000000..4156beed26b6e4f2b2f03442ddb= 01043d411c34f GIT binary patch literal 6585 zcmV;q8Aj$GiwFo|0{vS6128Z$I4yKxXLBuXWo2Y7IAUpZEoE+FZ)9n1XD)4GZ+HOQ zT76UEN|*oJe2T8A+A3U3=3D+1lMaGyb56a_^~7U(kd){4g?+AH-3T(d0{PWwuA3g(#VDwRz^z zF!OCI^P`aO({w(|QWFJB;U)5-!18B;9RpT=3D%Aw$c=3Dp7!e~dk;8~X z6uD>;&e_<=3Dp{YL!t&FBf#JWI;E{KvM5Di%=3DifIz~SwXrmw!YEu%$e0YQ#Ll@a#Z`Dik>jWN4UF$m3nmis(HDM_ z&7+r>oO!NKvw0HoJuCA}^!fK^{sTs^DPZlGhz*ZsewwAi28hx-@xSdpKOCa*>OJDz z!Ly%vXwV(@2FQ01QDjM!RS{#X>7t4SP1ki<5j91{GC4-wC_F-ZC|fjCYA*c% z$%00JutY|GPp~N(rmTbb3dZjR zr<2Ln^1ymv0DDVS3>jeKD!IP;qvBEDqs`kerT1ysrOfv1s;)z&D_6F3p zQtuZ{Hx*^SXbn2{t&pdTF<^a1(wy@&wgNu2tuTbm_jd%anE*0f@jZ`f5pApN~8jRhrGav#s`-9qJtvPrU74@-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g6TpArZR8l0tLN~P+#d}(wi*g-!}S98%f|nSgT$9liu-1&DLmDlv?8YVusFvYou@L zz6U-%-JwY)uBVO-Ax0vLfAJaZ&?Eoqnu$P%G~NM8zG{ZYH', payload) + if __name__ =3D=3D '__main__': main() diff --git a/www/views.py b/www/views.py index 45f63c8..2aae127 100644 --- a/www/views.py +++ b/www/views.py @@ -17,6 +17,7 @@ from django.utils.html import format_html from django.conf import settings import api import email +import quopri from mbox import decode_payload import re from mod import dispatch_module_hook @@ -292,7 +293,15 @@ def view_mbox(request, project, message_id): return msg.as_bytes(unixfrom=3DTrue) =20 payload =3D decode_payload(container) - container.set_payload('\n'.join(mbox_with_tags_iter(payload, m.tag= s))) + # We might be adding 8-bit trailers to a message with 7bit CTE. F= or + # patches, quoted-printable is safe and mostly human-readable. + try: + container.replace_header('Content-Transfer-Encoding', 'quoted-= printable') + except: + msg.add_header('Content-Transfer-Encoding', 'quoted-printable') + payload =3D '\n'.join(mbox_with_tags_iter(payload, m.tags)) + payload =3D quopri.encodestring(payload.encode('utf-8')) + container.set_payload(payload, charset=3D'utf-8') return msg.as_bytes(unixfrom=3DTrue) =20 s =3D api.models.Message.objects.find_message(message_id, project) --=20 2.19.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel