comparison libpurple/util.c @ 17195:d8102e923bd1

merge of '6314e2458eb034f1157174edc1f80ea8bb7ecebc' and 'b2b0435d92302ced9beab7521249fd500aa6221b'
author William Ehlhardt <williamehlhardt@gmail.com>
date Tue, 22 May 2007 22:46:07 +0000
parents cc9242ce1435 51f8dac490d7
children 3d035cdd103b ba768014f91f 1b74553c5c08
comparison
equal deleted inserted replaced
17038:5a308f09c871 17195:d8102e923bd1
1872 (!g_ascii_strncasecmp(c, "https://", 8)))) { 1872 (!g_ascii_strncasecmp(c, "https://", 8)))) {
1873 t = c; 1873 t = c;
1874 while (1) { 1874 while (1) {
1875 if (badchar(*t) || badentity(t)) { 1875 if (badchar(*t) || badentity(t)) {
1876 1876
1877 if ((!g_ascii_strncasecmp(c, "http://", 7) && (t - c == 7)) ||
1878 (!g_ascii_strncasecmp(c, "https://", 8) && (t - c == 8))) {
1879 break;
1880 }
1881
1877 if (*(t) == ',' && (*(t + 1) != ' ')) { 1882 if (*(t) == ',' && (*(t + 1) != ' ')) {
1878 t++; 1883 t++;
1879 continue; 1884 continue;
1880 } 1885 }
1881 1886
1931 } 1936 }
1932 } else if (!g_ascii_strncasecmp(c, "ftp://", 6) || !g_ascii_strncasecmp(c, "sftp://", 7)) { 1937 } else if (!g_ascii_strncasecmp(c, "ftp://", 6) || !g_ascii_strncasecmp(c, "sftp://", 7)) {
1933 t = c; 1938 t = c;
1934 while (1) { 1939 while (1) {
1935 if (badchar(*t) || badentity(t)) { 1940 if (badchar(*t) || badentity(t)) {
1941
1942 if ((!g_ascii_strncasecmp(c, "ftp://", 6) && (t - c == 6)) ||
1943 (!g_ascii_strncasecmp(c, "sftp://", 7) && (t - c == 7))) {
1944 break;
1945 }
1946
1936 if (*(t - 1) == '.') 1947 if (*(t - 1) == '.')
1937 t--; 1948 t--;
1938 if ((*(t - 1) == ')' && (inside_paren > 0))) { 1949 if ((*(t - 1) == ')' && (inside_paren > 0))) {
1939 t--; 1950 t--;
1940 } 1951 }
1982 } 1993 }
1983 } else if (!g_ascii_strncasecmp(c, "mailto:", 7)) { 1994 } else if (!g_ascii_strncasecmp(c, "mailto:", 7)) {
1984 t = c; 1995 t = c;
1985 while (1) { 1996 while (1) {
1986 if (badchar(*t) || badentity(t)) { 1997 if (badchar(*t) || badentity(t)) {
1998 char *d;
1999 if (t - c == 7) {
2000 break;
2001 }
1987 if (*(t - 1) == '.') 2002 if (*(t - 1) == '.')
1988 t--; 2003 t--;
2004 if ((d = strstr(c + 7, "?")) != NULL && d < t)
2005 url_buf = g_strndup(c + 7, d - c - 7);
2006 else
2007 url_buf = g_strndup(c + 7, t - c - 7);
2008 if (!purple_email_is_valid(url_buf)) {
2009 g_free(url_buf);
2010 break;
2011 }
2012 g_free(url_buf);
1989 url_buf = g_strndup(c, t - c); 2013 url_buf = g_strndup(c, t - c);
1990 tmpurlbuf = purple_unescape_html(url_buf); 2014 tmpurlbuf = purple_unescape_html(url_buf);
1991 g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>", 2015 g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>",
1992 tmpurlbuf, url_buf); 2016 tmpurlbuf, url_buf);
1993 g_free(url_buf); 2017 g_free(url_buf);
1995 c = t; 2019 c = t;
1996 break; 2020 break;
1997 } 2021 }
1998 if (!t) 2022 if (!t)
1999 break; 2023 break;
2024 t++;
2025
2026 }
2027 } else if ((*c=='x') && (!g_ascii_strncasecmp(c, "xmpp:", 5)) &&
2028 (c == text || badchar(c[-1]) || badentity(c-1))) {
2029 t = c;
2030 while (1) {
2031 if (badchar(*t) || badentity(t)) {
2032
2033 if (t - c == 5) {
2034 break;
2035 }
2036
2037 if (*(t) == ',' && (*(t + 1) != ' ')) {
2038 t++;
2039 continue;
2040 }
2041
2042 if (*(t - 1) == '.')
2043 t--;
2044 if ((*(t - 1) == ')' && (inside_paren > 0))) {
2045 t--;
2046 }
2047
2048 url_buf = g_strndup(c, t - c);
2049 tmpurlbuf = purple_unescape_html(url_buf);
2050 g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>",
2051 tmpurlbuf, url_buf);
2052 g_free(url_buf);
2053 g_free(tmpurlbuf);
2054 c = t;
2055 break;
2056 }
2000 t++; 2057 t++;
2001 2058
2002 } 2059 }
2003 } else if (c != text && (*c == '@')) { 2060 } else if (c != text && (*c == '@')) {
2004 int flag; 2061 int flag;
4156 iter = str; 4213 iter = str;
4157 for (; *iter && j < (BUF_LEN - 1) ; iter = g_utf8_next_char(iter)) { 4214 for (; *iter && j < (BUF_LEN - 1) ; iter = g_utf8_next_char(iter)) {
4158 gunichar c = g_utf8_get_char(iter); 4215 gunichar c = g_utf8_get_char(iter);
4159 /* If the character is an ASCII character and is alphanumeric, 4216 /* If the character is an ASCII character and is alphanumeric,
4160 * or one of the specified values, no need to escape */ 4217 * or one of the specified values, no need to escape */
4161 if (c < 128 && (isalnum(c) || c == '@' || c == '-' || 4218 if (c < 128 && (g_ascii_isalnum(c) || c == '@' || c == '-' ||
4162 c == '_' || c == '.' || c == '#')) { 4219 c == '_' || c == '.' || c == '#')) {
4163 buf[j++] = c; 4220 buf[j++] = c;
4164 } else { 4221 } else {
4165 int bytes = g_unichar_to_utf8(c, utf_char); 4222 int bytes = g_unichar_to_utf8(c, utf_char);
4166 for (i = 0; i < bytes; i++) { 4223 for (i = 0; i < bytes; i++) {