# HG changeset patch # User Daniel Atallah # Date 1224870152 0 # Node ID e0cfdf4a5a38954f77d0d7c018ae7fc431b8fbf5 # Parent 15c30a63f12434f8eafe18218aff8aac5b7ece77 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 diff -r 15c30a63f124 -r e0cfdf4a5a38 pidgin/gtkimhtml.c --- a/pidgin/gtkimhtml.c Fri Oct 24 04:19:10 2008 +0000 +++ b/pidgin/gtkimhtml.c Fri Oct 24 17:42:32 2008 +0000 @@ -2529,12 +2529,20 @@ { 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 @@ /* Find the subsequent contiguous digits */ v_start = tmp; + if (*v_start == '-') + tmp++; while (*tmp && g_ascii_isdigit(*tmp)) tmp++;