changeset 27885:1e9d17432a26

handle '[' and ']' as like '(' and ')'.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Sat, 06 Sep 2008 17:35:09 +0000
parents 48b32e603c76
children faee69fed1c2
files libpurple/util.c
diffstat 1 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/util.c	Sat Sep 06 16:10:18 2008 +0000
+++ b/libpurple/util.c	Sat Sep 06 17:35:09 2008 +0000
@@ -2037,7 +2037,6 @@
 	case '>':
 	case '"':
 	case '\'':
-	case ']':
 		return TRUE;
 	default:
 		return FALSE;
@@ -2063,6 +2062,7 @@
 	gunichar g;
 	gboolean inside_html = FALSE;
 	int inside_paren = 0;
+	int inside_bracket = 0;
 	GString *ret;
 
 	if (text == NULL)
@@ -2079,6 +2079,12 @@
 			c++;
 		}
 
+		if(*c == '[' && !inside_html) {
+			inside_bracket++;
+			ret = g_string_append_c(ret, *c);
+			c++;
+		}
+
 		if(inside_html) {
 			if(*c == '>') {
 				inside_html = FALSE;
@@ -2123,6 +2129,9 @@
 					if ((*(t - 1) == ')' && (inside_paren > 0))) {
 						t--;
 					}
+					if ((*(t - 1) == ']' && (inside_bracket > 0))) {
+						t--;
+					}
 
 					url_buf = g_strndup(c, t - c);
 					tmpurlbuf = purple_unescape_html(url_buf);
@@ -2155,6 +2164,9 @@
 						if ((*(t - 1) == ')' && (inside_paren > 0))) {
 							t--;
 						}
+						if ((*(t - 1) == ']' && (inside_bracket > 0))) {
+							t--;
+						}
 						url_buf = g_strndup(c, t - c);
 						tmpurlbuf = purple_unescape_html(url_buf);
 						g_string_append_printf(ret,
@@ -2183,6 +2195,9 @@
 					if ((*(t - 1) == ')' && (inside_paren > 0))) {
 						t--;
 					}
+					if ((*(t - 1) == ']' && (inside_bracket > 0))) {
+						t--;
+					}
 					url_buf = g_strndup(c, t - c);
 					tmpurlbuf = purple_unescape_html(url_buf);
 					g_string_append_printf(ret, "<A HREF=\"%s\">%s</A>",
@@ -2210,6 +2225,9 @@
 						if ((*(t - 1) == ')' && (inside_paren > 0))) {
 							t--;
 						}
+						if ((*(t - 1) == ']' && (inside_bracket > 0))) {
+							t--;
+						}
 						url_buf = g_strndup(c, t - c);
 						tmpurlbuf = purple_unescape_html(url_buf);
 						g_string_append_printf(ret,
@@ -2278,6 +2296,9 @@
 					if ((*(t - 1) == ')' && (inside_paren > 0))) {
 						t--;
 					}
+					if ((*(t - 1) == ']' && (inside_bracket > 0))) {
+						t--;
+					}
 
 					url_buf = g_strndup(c, t - c);
 					tmpurlbuf = purple_unescape_html(url_buf);
@@ -2365,6 +2386,11 @@
 			ret = g_string_append_c(ret, *c);
 			c++;
 		}
+		if(*c == ']' && !inside_html) {
+			inside_bracket--;
+			ret = g_string_append_c(ret, *c);
+			c++;
+		}
 
 		if (*c == 0)
 			break;