Mercurial > pidgin.yaz
changeset 10902:acaf64c659b9
[gaim-migrate @ 12624]
I hope all you people in the UK have voted.
This fixes some linkificationation stuff.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Fri, 06 May 2005 00:14:30 +0000 |
parents | 0711078e0e2d |
children | c153119be7d0 |
files | src/util.c |
diffstat | 1 files changed, 20 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/util.c Thu May 05 18:31:36 2005 +0000 +++ b/src/util.c Fri May 06 00:14:30 2005 +0000 @@ -1415,8 +1415,7 @@ gaim_markup_linkify(const char *text) { const char *c, *t, *q = NULL; - char *tmp, *tmpurlbuf; - char url_buf[BUF_LEN * 4]; + char *tmp, *tmpurlbuf, *url_buf; gunichar g; gboolean inside_html = FALSE; int inside_paren = 0; @@ -1472,11 +1471,11 @@ t--; } - strncpy(url_buf, c, t - c); - url_buf[t - c] = 0; + url_buf = g_strndup(c, t - c); tmpurlbuf = gaim_unescape_html(url_buf); g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>", tmpurlbuf, url_buf); + g_free(url_buf); g_free(tmpurlbuf); c = t; break; @@ -1505,12 +1504,12 @@ if ((*(t - 1) == ')' && (inside_paren > 0))) { t--; } - strncpy(url_buf, c, t - c); - url_buf[t - c] = 0; + url_buf = g_strndup(c, t - c); tmpurlbuf = gaim_unescape_html(url_buf); g_string_append_printf(ret, "<A HREF=\"http://%s\">%s</A>", tmpurlbuf, url_buf); + g_free(url_buf); g_free(tmpurlbuf); c = t; break; @@ -1529,11 +1528,11 @@ if ((*(t - 1) == ')' && (inside_paren > 0))) { t--; } - strncpy(url_buf, c, t - c); - url_buf[t - c] = 0; + g_strndup(c, t - c); tmpurlbuf = gaim_unescape_html(url_buf); g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>", tmpurlbuf, url_buf); + g_free(url_buf); g_free(tmpurlbuf); c = t; break; @@ -1556,12 +1555,12 @@ if ((*(t - 1) == ')' && (inside_paren > 0))) { t--; } - strncpy(url_buf, c, t - c); - url_buf[t - c] = 0; + url_buf = g_strndup(c, t - c); tmpurlbuf = gaim_unescape_html(url_buf); g_string_append_printf(ret, "<A HREF=\"ftp://%s\">%s</A>", tmpurlbuf, url_buf); + g_free(url_buf); g_free(tmpurlbuf); c = t; break; @@ -1577,11 +1576,11 @@ if (badchar(*t) || badentity(t)) { if (*(t - 1) == '.') t--; - strncpy(url_buf, c, t - c); - url_buf[t - c] = 0; + url_buf = g_strndup(c, t - c); tmpurlbuf = gaim_unescape_html(url_buf); g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>", tmpurlbuf, url_buf); + g_free(url_buf); g_free(tmpurlbuf); c = t; break; @@ -1595,15 +1594,15 @@ int flag; GString *gurl_buf; const char illegal_chars[] = "!@#$%^&*()[]{}/|\\<>\":;\r\n \0"; - url_buf[0] = 0; if (strchr(illegal_chars,*(c - 1)) || strchr(illegal_chars, *(c + 1))) flag = 0; - else + else { flag = 1; + gurl_buf = g_string_new(""); + } t = c; - gurl_buf = g_string_new(""); while (flag) { /* iterate backwards grabbing the local part of an email address */ g = g_utf8_get_char(t); @@ -1631,11 +1630,13 @@ if (badchar(*t) || (g >= 127) || (*t == ')') || badentity(t)) { char *d; - strcpy(url_buf, gurl_buf->str); + url_buf = g_string_free(gurl_buf, FALSE); /* strip off trailing periods */ - for (d = url_buf + strlen(url_buf) - 1; *d == '.'; d--, t--) - *d = '\0'; + if (strlen(url_buf) > 0) { + for (d = url_buf + strlen(url_buf) - 1; *d == '.'; d--, t--) + *d = '\0'; + } tmpurlbuf = gaim_unescape_html(url_buf); if (gaim_email_is_valid(tmpurlbuf)) { @@ -1644,6 +1645,7 @@ } else { g_string_append(ret, url_buf); } + g_free(url_buf); g_free(tmpurlbuf); c = t; @@ -1653,7 +1655,6 @@ t = g_utf8_find_next_char(t, NULL); } } - g_string_free(gurl_buf, TRUE); } if(*c == ')' && !inside_html) {