diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-01-22 00:45:26 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-01-22 00:45:26 +0000 |
commit | 703a8b505cf698c310497086334408d44397d121 (patch) | |
tree | f507e15f3d6abbdb29ff4651a8f4e666dc844edc /src/parse/properties.c | |
parent | ca3a7f507ebdcbb4a1ae16fd28ce6a256a0f8861 (diff) | |
download | libcss-703a8b505cf698c310497086334408d44397d121.tar.gz libcss-703a8b505cf698c310497086334408d44397d121.tar.bz2 |
Move isDigit() and isHex() to utils.h.
Fix #rgb/#rrggbb parsing to ensure that the characters are valid hex digits.
svn path=/trunk/libcss/; revision=6167
Diffstat (limited to 'src/parse/properties.c')
-rw-r--r-- | src/parse/properties.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/parse/properties.c b/src/parse/properties.c index ea2635d..a3c598a 100644 --- a/src/parse/properties.c +++ b/src/parse/properties.c @@ -6479,7 +6479,10 @@ css_error parse_colour_specifier(css_language *c, if (token->type == CSS_TOKEN_IDENT) { /** \todo Parse colour names */ } else if (token->type == CSS_TOKEN_HASH) { - if (token->idata->len == 3) { + if (token->idata->len == 3 && + isHex(token->idata->data[0]) && + isHex(token->idata->data[1]) && + isHex(token->idata->data[2])) { r = charToHex(token->idata->data[0]); g = charToHex(token->idata->data[1]); b = charToHex(token->idata->data[2]); @@ -6487,7 +6490,13 @@ css_error parse_colour_specifier(css_language *c, r |= (r << 4); g |= (g << 4); b |= (b << 4); - } else if (token->idata->len == 6) { + } else if (token->idata->len == 6 && + isHex(token->idata->data[0]) && + isHex(token->idata->data[1]) && + isHex(token->idata->data[2]) && + isHex(token->idata->data[3]) && + isHex(token->idata->data[4]) && + isHex(token->idata->data[5])) { r = (charToHex(token->idata->data[0]) << 4); r |= charToHex(token->idata->data[1]); g = (charToHex(token->idata->data[2]) << 4); |