From 458dd9bdb4a0346b09112659af66b560cefa1d98 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Wed, 1 Mar 2023 11:35:54 +0100 Subject: Use email.policy.SMTP to be perfectly conforming with RFCs. Perhaps fixes: https://todo.sr.ht/~mcepl/pygn/6 --- mail2news.py | 4 ++-- news2mail.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mail2news.py b/mail2news.py index 6a7aaff..2f64f6c 100644 --- a/mail2news.py +++ b/mail2news.py @@ -66,14 +66,14 @@ class mail2news(object): msg[header] = value.strip() def __readfile(self, opt): - message = email.message_from_file(sys.stdin, policy=email.policy.default) + message = email.message_from_file(sys.stdin, policy=email.policy.SMTP) if (len(message) == 0) \ and message.get_payload().startswith('/'): msg_file_name = message.get_payload().strip() del message with open(msg_file_name, 'r') as msg_file: - message = email.message_from_file(msg_file, policy=email.policy.default) + message = email.message_from_file(msg_file, policy=email.policy.SMTP) # introduce nntpheads self.__add_header('Newsgroups', opt.newsgroup, message) diff --git a/news2mail.py b/news2mail.py index a92c7e5..33d2590 100644 --- a/news2mail.py +++ b/news2mail.py @@ -54,7 +54,7 @@ class news2mail(object): self.heads_dict = {} self.article, self.headers, self.body = [], [], [] self.message = self.__addheads( - email.message_from_file(sys.stdin, policy=email.policy.default)) + email.message_from_file(sys.stdin, policy=email.policy.SMTP)) def __addheads(self, msg): """add new header like X-Gateway: Received: -- cgit