sptoolkit/sptoolkit — pull request #167 by jgarman (2013-05-22 16:28:45+00:00)
Title: Make encoding explicit in call to html_entity_decode()

This fixes a bug exposed by using PHP versions < 5.4.0. The default encoding used by PHP versions < 5.4.0 is ISO-8859-1 (Latin-1) whereas the default encoding used by PHP versions >= 5.4.0 is UTF-8.

The Swift Mailer component expects that the input is well-formed UTF-8, so passing in Latin-1 data creates malformed UTF-8 input and causes the Swift Mailer's Quoted Printable MIME encoder to create malformed output. The bug will manifest itself by copying large quantities of the original (non-QP encoded) message into the output, causing duplicate text and other bad artifacts.

An example $message that exposes the bug:
```php
$message = "A AA AAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA";
```

Passing the $message above into html_entity_decode on PHP versions < 5.4.0 will produce a single byte 0xa0 for the non-breaking space characters, which is not valid UTF-8.