Mercurial > pidgin
changeset 10461:e94802fe3eaf
[gaim-migrate @ 11733]
I think this is a better fix for bug 1013543 (because it also fixes 1086228)
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Fri, 31 Dec 2004 14:02:10 +0000 |
parents | 83cfcb52d93b |
children | f7b32dd67bdf |
files | src/util.c |
diffstat | 1 files changed, 21 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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);