emersion/go-msgauth

authres: parse() function can't get correct quoted-string value

anhdowastaken opened this issue · 3 comments

Arcoding to https://tools.ietf.org/html/rfc8601:

     reasonspec = "reason" [CFWS] "=" [CFWS] value
                ; a free-form comment on the reason the given result
                ; was returned
   The "value" is as defined in Section 5.1 of [MIME], with
   "quoted-string" updated as specified in [RFC6532].

For example:

var parseTests = []msgauthTest{
...
	{
		value: "example.com;" +
			"dkim=pass reason=\"good signature\" header.i=@mail-router.example.net;",
		identifier: "example.com",
		results: []Result{
			&DKIMResult{Value: ResultPass, Reason: "good signature", Identifier: "@mail-router.example.net"},
		},
	},
}

Instead of good signature, value of Reason is "good.

Ah. This means the whole parsing logic will need to be reworked, since quoted-strings can contain ;.

parts := strings.Split(v, ";")

Thanks for your confirmation.

Btw, I think this line instead:

parts := strings.Fields(s)

Well, this one too indeed.