# HG changeset patch # User Stu Tomlinson # Date 1179673029 0 # Node ID fdd52f7651c71bb87a0695bd8e087b52c3884c9b # Parent c36124736326990c64d29313154bb6be848139ca Linkify xmpp: URIs Only linkify mailto: if a valid address is found Don't linkify "empty" http, https, ftp, or sftp URIs diff -r c36124736326 -r fdd52f7651c7 libpurple/util.c --- a/libpurple/util.c Sun May 20 14:21:50 2007 +0000 +++ b/libpurple/util.c Sun May 20 14:57:09 2007 +0000 @@ -1874,6 +1874,11 @@ while (1) { if (badchar(*t) || badentity(t)) { + if ((!g_ascii_strncasecmp(c, "http://", 7) && (t - c == 7)) || + (!g_ascii_strncasecmp(c, "https://", 8) && (t - c == 8))) { + break; + } + if (*(t) == ',' && (*(t + 1) != ' ')) { t++; continue; @@ -1933,6 +1938,12 @@ t = c; while (1) { if (badchar(*t) || badentity(t)) { + + if ((!g_ascii_strncasecmp(c, "ftp://", 6) && (t - c == 6)) || + (!g_ascii_strncasecmp(c, "sftp://", 7) && (t - c == 7))) { + break; + } + if (*(t - 1) == '.') t--; if ((*(t - 1) == ')' && (inside_paren > 0))) { @@ -1984,8 +1995,21 @@ t = c; while (1) { if (badchar(*t) || badentity(t)) { + char *d; + if (t - c == 7) { + break; + } if (*(t - 1) == '.') t--; + if ((d = strstr(c + 7, "?")) != NULL && d < t) + url_buf = g_strndup(c + 7, d - c - 7); + else + url_buf = g_strndup(c + 7, t - c - 7); + if (!purple_email_is_valid(url_buf)) { + g_free(url_buf); + break; + } + g_free(url_buf); url_buf = g_strndup(c, t - c); tmpurlbuf = purple_unescape_html(url_buf); g_string_append_printf(ret, "%s", @@ -2000,6 +2024,39 @@ t++; } + } else if ((*c=='x') && (!g_ascii_strncasecmp(c, "xmpp:", 5)) && + (c == text || badchar(c[-1]) || badentity(c-1))) { + t = c; + while (1) { + if (badchar(*t) || badentity(t)) { + + if (t - c == 5) { + break; + } + + if (*(t) == ',' && (*(t + 1) != ' ')) { + t++; + continue; + } + + if (*(t - 1) == '.') + t--; + if ((*(t - 1) == ')' && (inside_paren > 0))) { + t--; + } + + url_buf = g_strndup(c, t - c); + tmpurlbuf = purple_unescape_html(url_buf); + g_string_append_printf(ret, "%s", + tmpurlbuf, url_buf); + g_free(url_buf); + g_free(tmpurlbuf); + c = t; + break; + } + t++; + + } } else if (c != text && (*c == '@')) { int flag; GString *gurl_buf = NULL;