emersion / go-msgauth

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

Improve line folding algorithm #31

Open emersion opened 4 years ago

emersion commented 4 years ago

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 may want to fix these:

ludusrusso commented 4 years ago

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).

emersion commented 4 years ago

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

ludusrusso commented 4 years ago

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

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

wjywbs commented 4 years ago

By the way, #30 fixed the h= wrapping as well.