civicrm/civicrm-core — pull request #1892 by kenwest (2013-11-02 09:17:34+00:00)
Title: CRM-13690 - CiviMail - prevent html2text treating mailing tokens as relative URLs

When sending a CiviMail with no text part, the text part is generated from the HTML part using the html2text package.

This conversion occurs before token replacement, so html2text has to process links of the form "{action.forward}". html2text thinks these are relative links so it prefixes them giving "http://example.org/{action.forward}". The token processing then converts this to "http://example.org/http://example.org/civicrm/mailing/forward?..." which is invalid.

What it does is...
* Convert tokens in the HTML to a format html2text thinks is an absolute URL ("{action.unsubscribeUrl}" -> "token:{action.unsubscribeUrl}")
* Run html2text over that
* Convert the Text to undo the first step ("token:{action.unsubscribeUrl}" -> "{action.unsubscribeUrl}")
* Return the Text

Can someone who knows the token code better than I check ...
* The regular expressions for recognising tokens are OK
* The change doesn't interfere with other parts of the HTML (eg, "{" in CSS)