pidgin: df5c02c8: Make the CSS rgb() color parsing more ro...

datallah at pidgin.im datallah at pidgin.im
Fri Oct 24 13:45:56 EDT 2008


-----------------------------------------------------------------
Revision: df5c02c8721094e05bb76d7ac7c7cb1ad5da5186
Ancestor: 4ef430848d380eda5938f38a09d3560b83e3f91b
Author: datallah at pidgin.im
Date: 2008-10-24T17:42:32
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/df5c02c8721094e05bb76d7ac7c7cb1ad5da5186

Modified files:
        pidgin/gtkimhtml.c

ChangeLog: 

Make the CSS rgb() color parsing more robust.  khc noted that it wouldn't work
with "rgb (..." and I updated it to work with negative values as specified at
http://www.w3.org/TR/CSS2/syndata.html#color-units
References #7288

-------------- next part --------------
============================================================
--- pidgin/gtkimhtml.c	1e96a64b8209b49c9751afea1f9db538a6d81b02
+++ pidgin/gtkimhtml.c	6cdddf9f2611817a550d02adeba2068ea0730199
@@ -2529,12 +2529,20 @@ parse_css_color(gchar *in_color)
 {
 	char *tmp = in_color;
 
-	if (*tmp == 'r' && *(++tmp) == 'g' && *(++tmp) == 'b'
-			&& *(++tmp) == '(' && *(++tmp)) {
+	if (*tmp == 'r' && *(++tmp) == 'g' && *(++tmp) == 'b' && *(++tmp)) {
 		int rgbval[] = {0, 0, 0};
 		int count = 0;
 		const char *v_start;
 
+		while (*tmp && g_ascii_isspace(*tmp))
+			tmp++;
+		if (*tmp != '(') {
+			/* We don't support rgba() */
+			purple_debug_warning("gtkimhtml", "Invalid rgb CSS color in '%s'!\n", in_color);
+			return in_color;
+		}
+		tmp++;
+
 		while (count < 3) {
 			/* Skip any leading spaces */
 			while (*tmp && g_ascii_isspace(*tmp))
@@ -2542,6 +2550,8 @@ parse_css_color(gchar *in_color)
 
 			/* Find the subsequent contiguous digits */
 			v_start = tmp;
+			if (*v_start == '-')
+				tmp++;
 			while (*tmp && g_ascii_isdigit(*tmp))
 				tmp++;
 


More information about the Commits mailing list