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,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.125.123]) by gnuweeb.org (Postfix) with ESMTPSA id 5004981214; Sat, 22 Oct 2022 06:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666421543; bh=C2t2lr0NQOaCfAlYGix5UE2f9eCxozq1A3T/Jbbam2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ezyop7lKwnAcV9tc6JH7PS3fHMRdfOSyf/IkLVNN8ePw7KOHS632MFoOEkC0SrKLk EYA/4U3TtZKH2pAn1DOUtyy9oct2tfCBpuoWW5HspHpXgLQi1ke6Lbg6ZaSlUQNu9j GqqERnznKqNVh8tW0BP4yg5u4yy0M+nqSP6VqQn39dcXaT93u6aZFcKXoMYlEuwF9e Rc1NfTI3Fj787L0k8qbmQCL64mUBRboh1lt/7UZHWHLMNf+zmHAdxXsqyQtoEng0WP PPmZD9tsqgICPSKAD+R1WdRExk+Nx+mKC6NpFJnb5uWPC+xbsZ7poCZ/jpuBtw8bHP UE3pusDAC6NHg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v4 7/9] atom: Improve extract_body() Date: Sat, 22 Oct 2022 13:51:47 +0700 Message-Id: <20221022065149.865-8-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221022065149.865-1-kiizuha@gnuweeb.org> References: <20221022065149.865-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 --- 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 -- Muhammad Rizki