From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.125.209]) by gnuweeb.org (Postfix) with ESMTPSA id 999798191C; Mon, 19 Dec 2022 23:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1671493982; bh=7H4U0hVfSesbuzQQyfftfID1NRVg9MB2iECXKhYxZNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BfW9KFtPoxJaADYeX6+KovRpCFxDw/KMTghspoiX/wnEJFmeyVoCPsERPteR2LXE0 lgC8wAQaP9fhqNHS0mvnZgkPTlwokEYbg2ik6nQPAIis3pA9IVztyG730zNEehLrZJ kut4pHzlJLWJfktesIVRJq843JIYdg6I52YQ2v04KW5JGBWe0GUoXi9w788CBN/TTr QmChHxltcQrxMb39QGCJ0BWdanl3Ba/9wPv6A3ZjllPRI99rlpAGsw3Lqzdl3K28aq HHDy4vItEGGVKxC/oHl0KNKeYvRzEsqER/nSFeLDod02vvipk87kwaiOwrVCGtNczv Ho5+1ehpg4i8Q== From: Muhammad Rizki To: Cc: Muhammad Rizki , Alviro Iskandar Setiawan , Ammar Faizi , GNU/Weeb Mailing List Subject: [PATCH 07/28] atom: Improve extract_body() Date: Tue, 20 Dec 2022 06:52:05 +0700 Message-Id: <20221219235226.1567-7-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221219235226.1567-1-kiizuha@gnuweeb.org> References: <20221219235226.1567-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Add an if statement to ignore whenever the email payload containing a text/html content-type header. v1 -> v2: - Simplify the usage to get the email header by using the library get function itself. Signed-off-by: Muhammad Rizki Reviewed-by: Alviro Iskandar Setiawan Link: https://lore.gnuweeb.org/gwml/20221022065149.865-8-kiizuha@gnuweeb.org Cc: Ammar Faizi Cc: GNU/Weeb Mailing List Signed-off-by: Ammar Faizi --- daemon/atom/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daemon/atom/utils.py b/daemon/atom/utils.py index deff99d..4383b03 100644 --- a/daemon/atom/utils.py +++ b/daemon/atom/utils.py @@ -151,10 +151,13 @@ def extract_body(thread: Message, platform: str): fname = p.get_filename() payload = p.get_payload(decode=True) + if p.get_content_type() == "text/html": + continue + if not payload: continue - if 'inline' in [p.get('content-disposition')] or not bool(fname): + if p.get_content_disposition() == 'inline' or not bool(fname): ret += f"{payload.decode(errors='replace')}\n".lstrip() continue -- 2.34.1.windows.1