# HG changeset patch # User Stu Tomlinson # Date 1104501730 0 # Node ID e94802fe3eafa3db90a67f31f01eb7f9aa3814f4 # Parent 83cfcb52d93bfbab843a9945b462503861d24ae0 [gaim-migrate @ 11733] I think this is a better fix for bug 1013543 (because it also fixes 1086228) committer: Tailor Script diff -r 83cfcb52d93b -r e94802fe3eaf src/util.c --- a/src/util.c Fri Dec 31 13:20:55 2004 +0000 +++ b/src/util.c Fri Dec 31 14:02:10 2004 +0000 @@ -1370,7 +1370,7 @@ return str2; } -static gint +static gboolean badchar(char c) { switch (c) { @@ -1382,12 +1382,23 @@ case '>': case '"': case '\'': - return 1; + return TRUE; default: - return 0; + return FALSE; } } +static gboolean +badentity(const char *c) +{ + if (!g_ascii_strncasecmp(c, "<", 4) || + !g_ascii_strncasecmp(c, ">", 4) || + !g_ascii_strncasecmp(c, """, 6)) { + return TRUE; + } + return FALSE; +} + char * gaim_markup_linkify(const char *text) { @@ -1436,7 +1447,7 @@ (!g_ascii_strncasecmp(c, "https://", 8)))) { t = c; while (1) { - if (badchar(*t)) { + if (badchar(*t) || badentity(t)) { if (*(t) == ',' && (*(t + 1) != ' ')) { t++; @@ -1448,8 +1459,7 @@ if ((*(t - 1) == ')' && (inside_paren > 0))) { t--; } - if (!g_ascii_strncasecmp(t - 6, """, 6)) - t -= 6; + strncpy(url_buf, c, t - c); url_buf[t - c] = 0; tmpurlbuf = gaim_unescape_html(url_buf); @@ -1468,7 +1478,7 @@ if (c[4] != '.') { t = c; while (1) { - if (badchar(*t)) { + if (badchar(*t) || badentity(t)) { if (t - c == 4) { break; } @@ -1501,7 +1511,7 @@ } else if (!g_ascii_strncasecmp(c, "ftp://", 6)) { t = c; while (1) { - if (badchar(*t)) { + if (badchar(*t) || badentity(t)) { if (*(t - 1) == '.') t--; if ((*(t - 1) == ')' && (inside_paren > 0))) { @@ -1525,7 +1535,7 @@ if (c[4] != '.') { t = c; while (1) { - if (badchar(*t)) { + if (badchar(*t) || badentity(t)) { if (t - c == 4) { break; } @@ -1552,7 +1562,7 @@ } else if (!g_ascii_strncasecmp(c, "mailto:", 7)) { t = c; while (1) { - if (badchar(*t)) { + if (badchar(*t) || badentity(t)) { if (*(t - 1) == '.') t--; strncpy(url_buf, c, t - c); @@ -1606,8 +1616,7 @@ while (flag) { /* iterate forwards grabbing the domain part of an email address */ g = g_utf8_get_char(t); - if (badchar(*t) || (g >= 127) || (*t == ')') || - ((*t == '&') && !g_ascii_strncasecmp(t, ">", 4))) { + if (badchar(*t) || (g >= 127) || (*t == ')') || badentity(t)) { char *d; strcpy(url_buf, gurl_buf->str);