LABKEY.Message.sendMessage HTML encoding bug

LabKey Support Forum (Inactive)
LABKEY.Message.sendMessage HTML encoding bug Will Holtz  2016-01-19 11:37
Status: Closed
 
I just noticed that when I upgraded to v15.3 from v15.2, one of my calls to LABKEY.Message.sendMessage() had a significant change in output and seems to be broken. Here is some code that produces the output in question:

<script type="text/javascript">

function getEmailAddress() {
        // Need a real user's email address due to labkey restrictions on email sending
    LABKEY.Query.selectRows({
            schemaName: 'core',
            queryName: 'users',
            columns: ['email'],
            maxRows: 1,
            success: emailURL,
            failure: function() {alert('No emails found!');}
        });
}

function emailURL(data, response) {
    var email = data.rows[0].Email;
    var url='http://www.labkey.org/';
    var msgConfig = {
             msgFrom: email,
             msgSubject: 'Test of URL in HTML email',
             msgRecipients: [
                 LABKEY.Message.createRecipient(LABKEY.Message.recipientType.to, email)
             ],
             msgContent: [
                 LABKEY.Message.createMsgContent(LABKEY.Message.msgType.html,
            'A test <a href="' + url + '">link</a> to labkey.org')
             ],
             failure: function(errorInfo, responseObj) {
                alert('Failed to send email. '+errorInfo.exception);
             }
        };
    LABKEY.Message.sendMessage(msgConfig);
}


Ext4.onReady(function() {
    getEmailAddress();
});

</script>

With v15.3 I get an email containing:
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

A test &lt;a href=&quot;<a href="http://www.labkey.org/&quot;&gt;link&lt;/a&gt;">http://www.labkey.org/&quot;&gt;link&lt;/a&gt;</a> to labkey.org

I haven't run this exact code under v15.2 (as I don't have v15.2 handy anymore), but I have some old emails created by similar code on v15.2 and I believe the output from v15.2 would be:
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

A test <a href="http://www.labkey.org/">link</a> to labkey.org

The message generated by v15.3 results in the follow DOM (using Chrome v47.0 and viewing the message in Gmail):
A test &lt;a href="<a href="http://www.labkey.org/%22%3Elink%3C/a%3E" target="_blank">http://www.labkey.org/"&gt;<wbr>link&lt;/a&gt;</a> to <a href="http://labkey.org" target="_blank">labkey.org</a>

Which doesn't seem to be what I asked for in my call to LABKEY.Message.sendMessage. Let me know if that all makes sense.

thanks,
-Will
 
 
Will Holtz responded:  2016-01-19 12:49
I should probably add that in the DOM that I gave above, the 'A' tag in '<a href="http://labkey.org" target="_blank">labkey.org</a>' part was added by Gmail...

-Will
 
Jon (LabKey DevOps) responded:  2016-01-21 17:08
Hi Will,

According to our developers, this was caused by revision r40111 which was supposed to consolidate HTML filtering. This has been corrected and will be bundled in the 16.1 release.

If you do need this sooner, feel free to download the development trunk build we have out here:

https://teamcity.labkey.org/repository/download/bt127/298417:id/community/LabKey16.1Dev-42003.977-community-bin.zip

Regards,

Jon