* [PATCH] devel/nmweb: read mail files in binary mode.
@ 2023-09-16 14:24 David Bremner
2023-09-17 15:24 ` Tomi Ollila
0 siblings, 1 reply; 3+ messages in thread
From: David Bremner @ 2023-09-16 14:24 UTC (permalink / raw)
To: notmuch
"ju" reported on IRC that browsing
https://nmbug.notmuchmail.org/nmweb/show/20160719094205.qmf5sjnja6crt5t3%40gotlib
crashed. The underlying issue is that python3 defaults to utf8
decoding files unless they are opened in binary mode. The file in
question (in the nmbug archive; it depends a bit on the routing the
message took) has
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
and some of it is not valid utf8.
---
I have already deployed this as a hotfix, but not applied it to master or release.
devel/notmuch-web/nmweb.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/devel/notmuch-web/nmweb.py b/devel/notmuch-web/nmweb.py
index b0d4d5cd..e0e87b49 100755
--- a/devel/notmuch-web/nmweb.py
+++ b/devel/notmuch-web/nmweb.py
@@ -207,7 +207,7 @@ env.globals['thread_nav'] = thread_nav
def format_message(nm_msg, mid):
fn = list(nm_msg.filenames())[0]
- msg = MaildirMessage(open(fn))
+ msg = MaildirMessage(open(fn, 'rb'))
return format_message_walk(msg, mid)
def decodeAnyway(txt, charset='ascii'):
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] devel/nmweb: read mail files in binary mode.
2023-09-16 14:24 [PATCH] devel/nmweb: read mail files in binary mode David Bremner
@ 2023-09-17 15:24 ` Tomi Ollila
2023-09-18 9:22 ` David Bremner
0 siblings, 1 reply; 3+ messages in thread
From: Tomi Ollila @ 2023-09-17 15:24 UTC (permalink / raw)
To: David Bremner, notmuch
On Sat, Sep 16 2023, David Bremner wrote:
> "ju" reported on IRC that browsing
>
> https://nmbug.notmuchmail.org/nmweb/show/20160719094205.qmf5sjnja6crt5t3%40gotlib
>
> crashed. The underlying issue is that python3 defaults to utf8
> decoding files unless they are opened in binary mode. The file in
> question (in the nmbug archive; it depends a bit on the routing the
> message took) has
>
> Content-Type: text/plain; charset=iso-8859-1
> Content-Transfer-Encoding: 8bit
>
> and some of it is not valid utf8.
> ---
Looks good to me. I've been experiencing "text" mode defaulting to 'ascii'
(and had to include encoding='utf-8') lately. Another problem one may
encounter when there are \r chars in the file, text mode may remove those
(In the same case I had a file using '\r\r' as list content separator,
and failed until changing open to binary mode)
Tomi
>
> I have already deployed this as a hotfix, but not applied it to master or release.
>
>
> devel/notmuch-web/nmweb.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/devel/notmuch-web/nmweb.py b/devel/notmuch-web/nmweb.py
> index b0d4d5cd..e0e87b49 100755
> --- a/devel/notmuch-web/nmweb.py
> +++ b/devel/notmuch-web/nmweb.py
> @@ -207,7 +207,7 @@ env.globals['thread_nav'] = thread_nav
>
> def format_message(nm_msg, mid):
> fn = list(nm_msg.filenames())[0]
> - msg = MaildirMessage(open(fn))
> + msg = MaildirMessage(open(fn, 'rb'))
> return format_message_walk(msg, mid)
>
> def decodeAnyway(txt, charset='ascii'):
> --
> 2.40.1
>
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] devel/nmweb: read mail files in binary mode.
2023-09-17 15:24 ` Tomi Ollila
@ 2023-09-18 9:22 ` David Bremner
0 siblings, 0 replies; 3+ messages in thread
From: David Bremner @ 2023-09-18 9:22 UTC (permalink / raw)
To: Tomi Ollila, notmuch
Tomi Ollila <tomi.ollila@iki.fi> writes:
>
> Looks good to me. I've been experiencing "text" mode defaulting to 'ascii'
> (and had to include encoding='utf-8') lately. Another problem one may
> encounter when there are \r chars in the file, text mode may remove those
> (In the same case I had a file using '\r\r' as list content separator,
> and failed until changing open to binary mode)
>
> Tomi
>
thanks for the review. Applied to master and deployed that (again) to
nmbug.notmuchmail.org. Probably I should think of a deployment method
that does not involve git merge :(.
d
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-18 9:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-16 14:24 [PATCH] devel/nmweb: read mail files in binary mode David Bremner
2023-09-17 15:24 ` Tomi Ollila
2023-09-18 9:22 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).