go-msgauth
go-msgauth copied to clipboard
Improve line folding algorithm
With https://github.com/emersion/go-msgauth/pull/29 we no longer generate broken signatures with FWS where they shouldn't be. However we could still improve our folding algorithm. Given these constraints:
- We want to be RFC-conformant (lines < 1000 chars)
- We don't want something too complicated (see https://github.com/emersion/go-msgauth/pull/27)
- Ensuring that lines are <75 chars is not necessary
We may want to fix these:
- We still don't properly fold
h=params if they are very long - We fold
b=params at 75 chars, but we don't need to
I can work on it on the next days! :D
My idea is to write two simple functions, one to fold h and one for b (that we already have).
Nice!
I think to fold h, it'll probably be simpler to do it before turning the list into a string, ie. in formatTagList:
https://github.com/emersion/go-msgauth/blob/fb07ec9e7323788ae953eea6797a1dddb8a13106/dkim/sign.go#L340
Nice!
I think to fold
h, it'll probably be simpler to do it before turning the list into a string, ie. informatTagList:https://github.com/emersion/go-msgauth/blob/fb07ec9e7323788ae953eea6797a1dddb8a13106/dkim/sign.go#L340
Thats right, but I then need to change some piece of code in the middle, I thinks that it would be simpler by just use Strings.split in
https://github.com/emersion/go-msgauth/blob/fb07ec9e7323788ae953eea6797a1dddb8a13106/dkim/header.go#L95
By the way, #30 fixed the h= wrapping as well.