swiftmailer/swiftmailer — pull request #211 by arthens (2012-06-15 02:25:46+00:00)
Title: Fix address header encoding bug

This is a fix for issue #206:
https://github.com/swiftmailer/swiftmailer/issues/206

This problem happens when the name contains both special characters and commas or semicolons, but in different tokens.

Surnamé, Name is encoded correctly, because the the comma is part of the token with the special character, and therefore it will be encoded.
Surnamé ,Name will NOT be encoded correctly, because the comma is part of the fully-ASCII token and therefore won't be encoded.

This is a problem because commas and semicolons are used to separate addresses, and if not quoted or encoded they will produce an invalid address header.

My fix is to redefine the encoding requirements for mailboxes, adding commas and semicolons to the list of characters that force the token to be encoded.
I've also added a regression test to make sure this problem is not re-introduced in future.