Github messages for voidlinux
 help / color / mirror / Atom feed
From: devvesa <devvesa@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] alot: patch mailcap rendering no content-type
Date: Sat, 31 Oct 2020 13:55:29 +0100	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-25997@inbox.vuxu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

There is a new pull request by devvesa against master on the void-packages repository

https://github.com/devvesa/void-packages alot_patch_no_content_type
https://github.com/void-linux/void-packages/pull/25997

alot: patch mailcap rendering no content-type
Add a patch to fix a rendering problem with mails without _Content-Type_
header.

Patch is based on a bug already fixed in master branch of the `alot` project:

https://github.com/pazz/alot/pull/1513

I find it important because without it, there is no way to see any mail
sent via `git send-email` on projects with email-driven git workflows.
Apparently, `git send-email` doesn't add the aforementioned header.

A patch file from https://github.com/void-linux/void-packages/pull/25997.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-alot_patch_no_content_type-25997.patch --]
[-- Type: text/x-diff, Size: 3864 bytes --]

From ec56e7e9bc918a05722e238d54f9fbdf5d416644 Mon Sep 17 00:00:00 2001
From: Jaume Devesa <jaume@mailbox.org>
Date: Sat, 31 Oct 2020 13:48:07 +0100
Subject: [PATCH] alot: patch mailcap rendering no content-type

Add a patch to fix a rendering problem with mails without Content-Type
header.

Patch is based on a bug already fixed in master in this PR:

https://github.com/pazz/alot/pull/1513

I find it important because without it, there is no way to see any mail
sent via `git send-email` on projects with email-driven git workflows.
Apparently, `git send-email` doesn't add the aforementioned header.
---
 ...ix-mailcap-rendering-no-content-type.patch | 65 +++++++++++++++++++
 srcpkgs/alot/template                         |  2 +-
 2 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/alot/patches/fix-mailcap-rendering-no-content-type.patch

diff --git a/srcpkgs/alot/patches/fix-mailcap-rendering-no-content-type.patch b/srcpkgs/alot/patches/fix-mailcap-rendering-no-content-type.patch
new file mode 100644
index 00000000000..e1aec812a58
--- /dev/null
+++ b/srcpkgs/alot/patches/fix-mailcap-rendering-no-content-type.patch
@@ -0,0 +1,65 @@
+From 0339a33818adc6fc33e83336f9eea289d5e7e893 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Ma=C4=8Ds?= <martins.macs@bi.lv>
+Date: Tue, 19 May 2020 13:48:17 +0300
+Subject: [PATCH] Fix mailcap rendering for e-mails without `Content-Type`
+ header
+
+`get_params()` returns `None` when the header is missing. Use `failobj`
+argument to mitigate that.
+
+Fixes #1512
+---
+ alot/db/utils.py            |  2 +-
+ tests/db/test_utils.py      | 10 ++++++++++
+ tests/static/mail/basic.eml |  5 +++++
+ 3 files changed, 16 insertions(+), 1 deletion(-)
+ create mode 100644 tests/static/mail/basic.eml
+
+diff --git a/alot/db/utils.py b/alot/db/utils.py
+index 27c85942..e55768b1 100644
+--- a/alot/db/utils.py
++++ b/alot/db/utils.py
+@@ -365,7 +365,7 @@ def render_part(part, field_key='copiousoutput'):
+             stdin = raw_payload
+ 
+         # read parameter, create handler command
+-        parms = tuple('='.join(p) for p in part.get_params())
++        parms = tuple('='.join(p) for p in part.get_params(failobj=[]))
+ 
+         # create and call external command
+         cmd = mailcap.subst(entry['view'], ctype,
+diff --git a/tests/db/test_utils.py b/tests/db/test_utils.py
+index 36ce77cf..40c2fb91 100644
+--- a/tests/db/test_utils.py
++++ b/tests/db/test_utils.py
+@@ -762,6 +762,16 @@ class TestExtractBodyPart(unittest.TestCase):
+ 
+         self.assertEqual(actual, expected)
+ 
++    @mock.patch('alot.db.utils.settings.mailcap_find_match',
++                mock.Mock(return_value=(None, {'view': 'cat'})))
++    def test_plaintext_mailcap_wo_content_type(self):
++        with open('tests/static/mail/basic.eml') as fp:
++            mail = email.message_from_file(fp,
++                    _class=email.message.EmailMessage)
++        body_part = utils.get_body_part(mail)
++        actual = utils.extract_body_part(body_part)
++        expected = 'test body\n'
++        self.assertEqual(actual, expected)
+ 
+ class TestRemoveCte(unittest.TestCase):
+ 
+diff --git a/tests/static/mail/basic.eml b/tests/static/mail/basic.eml
+new file mode 100644
+index 00000000..95f15693
+--- /dev/null
++++ b/tests/static/mail/basic.eml
+@@ -0,0 +1,5 @@
++From: me@localhost
++To: you@localhost
++Subject: test subject
++
++test body
+-- 
+2.29.2
+
diff --git a/srcpkgs/alot/template b/srcpkgs/alot/template
index 4d590485452..314bbe011aa 100644
--- a/srcpkgs/alot/template
+++ b/srcpkgs/alot/template
@@ -1,7 +1,7 @@
 # Template file for 'alot'
 pkgname=alot
 version=0.9.1
-revision=3
+revision=4
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Sphinx"
 depends="python3-setuptools python3-Twisted notmuch-python3 python3-configobj

             reply	other threads:[~2020-10-31 12:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-31 12:55 devvesa [this message]
2020-10-31 19:29 ` [PR PATCH] [Merged]: " ericonr

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 \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-25997@inbox.vuxu.org \
    --to=devvesa@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /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;
as well as URLs for NNTP newsgroup(s).