From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
GNU/Weeb Mailing List <[email protected]>,
Alviro Iskandar Setiawan <[email protected]>
Subject: [PATCH v1 2/2] Use html.escape() for fix_utf8_chars()
Date: Wed, 3 Aug 2022 17:27:18 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
We found a bug when receiving email payload like `<text>`, `®`, and
more. Using double html.escape() will fix the bug for now.
Signed-off-by: Muhammad Rizki <[email protected]>
Reported-by: Alviro Iskandar Setiawan <[email protected]>
---
daemon/scraper/utils.py | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/daemon/scraper/utils.py b/daemon/scraper/utils.py
index 765468c..c428a33 100644
--- a/daemon/scraper/utils.py
+++ b/daemon/scraper/utils.py
@@ -14,6 +14,7 @@ import os
import re
import shutil
import httpx
+import html
def get_email_msg_id(mail):
@@ -218,12 +219,8 @@ def clean_up_after_send_patch(tmp):
def fix_utf8_char(text: str):
- return (
- text.rstrip()
- .replace("<", "<")
- .replace(">",">")
- .replace("�"," ")
- )
+ text = text.rstrip().replace("�"," ")
+ return html.escape(html.escape(text))
EMAIL_MSG_ID_PATTERN = r"<([^\<\>]+)>"
--
Muhammad Rizki
next prev parent reply other threads:[~2022-08-03 10:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-03 10:27 [PATCH v1 0/2] Improve some utility codes Muhammad Rizki
2022-08-03 10:27 ` [PATCH v1 1/2] Improve code for bottom border Muhammad Rizki
2022-08-03 10:27 ` Muhammad Rizki [this message]
2022-08-03 12:49 ` [PATCH v1 2/2] Use html.escape() for fix_utf8_chars() Ammar Faizi
2022-08-03 12:53 ` Ammar Faizi
2022-08-03 13:01 ` Muhammad Rizki
2022-08-03 12:51 ` (subset) [PATCH v1 0/2] Improve some utility codes Ammar Faizi
2022-08-03 13:07 ` Ammar Faizi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox