emersion / go-msgauth

🔏 A Go library and tools for DKIM, DMARC and Authentication-Results
MIT License
162 stars 51 forks source link

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

Open anhdowastaken opened 4 years ago

anhdowastaken commented 4 years ago

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.

emersion commented 4 years ago

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

https://github.com/emersion/go-msgauth/blob/fb07ec9e7323788ae953eea6797a1dddb8a13106/authres/parse.go#L225

anhdowastaken commented 4 years ago

Thanks for your confirmation.

Btw, I think this line instead: https://github.com/emersion/go-msgauth/blob/fb07ec9e7323788ae953eea6797a1dddb8a13106/authres/parse.go#L258

emersion commented 4 years ago

Well, this one too indeed.