~sircmpwn/aerc

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH v2] pgp: recognize uppercase MIME signatures

impaqt
Details
Message ID
<20200521143459.782132-1-impaqt@vendek.net>
DKIM signature
pass
Download raw message
Patch: +4 -4
I got an email the other day with an "APPLICATION/PGP-SIGNATURE"
attachment that wasn't recognized because it wasn't a lowercase
"application/pgp-signature". Perhaps MIME types should be lowercased
globally upon parsing?
---
 lib/messageview.go | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/messageview.go b/lib/messageview.go
index 59a1af6..db0184b 100644
--- a/lib/messageview.go
+++ b/lib/messageview.go
@@ -4,6 +4,7 @@ import (
	"bytes"
	"io"
	"io/ioutil"
	"strings"

	"github.com/emersion/go-message"
	_ "github.com/emersion/go-message/charset"
@@ -34,10 +35,9 @@ type MessageView interface {
}

func usePGP(info *models.BodyStructure) bool {
	if info.MIMEType == "application" {
		if info.MIMESubType == "pgp-encrypted" ||
			info.MIMESubType == "pgp-signature" {

	if strings.ToLower(info.MIMEType) == "application" {
        subtype := strings.ToLower(info.MIMESubType)
		if subtype == "pgp-encrypted" || subtype == "pgp-signature" {
			return true
		}
	}
-- 
2.26.2
Details
Message ID
<20200521162631.6p7f2u4ww54tm4wg@feather.localdomain>
In-Reply-To
<20200521143459.782132-1-impaqt@vendek.net> (view parent)
DKIM signature
pass
Download raw message
On Thu, May 21, 2020 at 07:34:59AM -0700, impaqt wrote:
> I got an email the other day with an "APPLICATION/PGP-SIGNATURE"
> attachment that wasn't recognized because it wasn't a lowercase
> "application/pgp-signature". Perhaps MIME types should be lowercased
> globally upon parsing?

^ This will end up in the commit message and should not contain questions.

> ---

Here you can put "just in time" text for things like questions or anecdotes.
(Note the preceding ---)

> +	if strings.ToLower(info.MIMEType) == "application" {
> +        subtype := strings.ToLower(info.MIMESubType)
> +		if subtype == "pgp-encrypted" || subtype == "pgp-signature" {
>  			return true
>  		}
>  	}

This is still not properly formated.
As you've already been told:

>Please run `go fmt ./...` before sending a patch next time :)

This isn't to nag you, this is really how you should do it.
Most editors have functionality to do this automatically when you save.

Every go code on earth (at least most of it) looks the very same because everyone
uses the same formatting tool in go. You should follow suit.

Cheers,
Reto
impaqt
Details
Message ID
<C2WKRPAX8IN5.7U0YJCJKZG4J@jupiter>
In-Reply-To
<20200521162631.6p7f2u4ww54tm4wg@feather.localdomain> (view parent)
DKIM signature
pass
Download raw message
Ah, sorry. I see the issue. I've never written any Go before so I had
no tooling set up. I ran go fmt manually but forgot to git add the file
before amending my commit. I'm not being stubborn, just stupid; I
totally get the importance of automatic, agreed-upon formatting!

I removed my comments from the commit, but I don't really see what's
wrong with putting comments in the commit description in general. If
written in the email's comments and not the commit/patch itself, the
questions don't make it into the commit log, and are less likely to
be stumbled upon in the future. I see there are several other commits
in the log that pose questions about further refactoring, like 92f59ef.
At the very least, the rationale for the change (in this case, the fact
that emails are arriving with uppercase MIME signatures) should be
documented in the commit description, no?
Review patch Export thread (mbox)