Only add closing quote to href token output when necessary
Lines 1345 to 1350 of CRM/Mailing/BAO/Mailing.php add a trailing quote to tokens of 'type' embedded_url
as according to the code:
// add trailing quote since we've gobbled it up in a previous regex
// function getPatterns, line 431
In my testing, sometimes the trailing quote is not gobbled, e.g. in this example <p><a href="https://example.org/communication-preferences?cid1={contact.contact_id}&{contact.checksum}">Click here to select your communication preferences</a></p>
.
As a fix, I am proposing to only add a closing quote if the url does not already have one.