About libpurple's g_markup_escape_text() bug

Ethan Blanton elb at psg.com
Mon Oct 10 16:00:19 EDT 2011

Diego sent me this email about other SILC prpl errors.  I believe I
replied and Cc'd the list at the time, but I'm not sure, and I don't
want this to get lost.

Diego Bauche Madero spake unto us the following wisdom:
> The bug is also present on silc_channel_message() with the UTF8 flag,
> there's also other flags that also trigger the use of
> g_markup_escape_text().

I have attached a[n untested] patch which fixes some MOTD handling.

There are many places in the SILC prpl which will have essentially
this same structure.  I would *really* like to add a utility function
to handle this in one go, both to prevent errors and to simplify
usage, but I hate to trigger 2.11.0 and confuse people.  Maybe it
belongs in SILC for now.  In any event, 3.0.0 probably ought to
provide something like this:

char *purple_utf8_salvage_and_escape(char *str)
    char *escaped;

    if (g_utf8_validate(str, -1, NULL)) {
        escaped = g_markup_escape_text(str, -1);
    } else {
        char *tmp = purple_utf8_salvage(str);
        escaped = g_markup-escape_text(tmp, -1);

    return escaped;

I had been meaning to audit more of the SILC prpl before release,
since its erroneous nature has been outed already.  The attached patch
was my start on that quest.  However, I am just not going to have the
opportunity to do it in a timely fashion.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pidgin-silc-motd-utf8.diff
Type: text/x-diff
Size: 1357 bytes
Desc: not available
URL: <http://pidgin.im/cgi-bin/mailman/private/security/attachments/20111010/0c227b7b/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: Digital signature
URL: <http://pidgin.im/cgi-bin/mailman/private/security/attachments/20111010/0c227b7b/attachment.pgp>

More information about the security mailing list