diff options
author | Bruno Haible <bruno@clisp.org> | 2007-01-10 21:37:00 +0000 |
---|---|---|
committer | Dom Lachowicz <doml@src.gnome.org> | 2007-01-10 21:37:00 +0000 |
commit | 5066d38ceca39591045d7fd506760f83309ac35f (patch) | |
tree | 1c4b07fafe49a40f68dae3c8e0fa320886fdcf3f | |
parent | ef258807ec53ed9639dd68e897de98dbe81f408c (diff) | |
download | libcroco-5066d38ceca39591045d7fd506760f83309ac35f.tar.gz |
Bug 395099 - overly agressive rule matching
2007-01-10 Bruno Haible <bruno@clisp.org>
* cr-sel-eng.c: Bug 395099 - overly agressive rule matching
svn path=/trunk/; revision=312
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/cr-sel-eng.c | 10 |
2 files changed, 8 insertions, 3 deletions
@@ -3,6 +3,7 @@ * cr-style.h (enum CRPositionType): Remove trailing comma. Needed for compilation on AIX with xlc. * cr-fonts.c (cr_font_weight_get_bolder): Handle FONT_WEIGHT_INHERIT. + * cr-sel-eng.c: Bug 395099 - overly agressive rule matching 2007-01-09 Benjamin Dauvergne <feanor@tol-eressea.org> diff --git a/src/cr-sel-eng.c b/src/cr-sel-eng.c index 5b72e09..261314c 100644 --- a/src/cr-sel-eng.c +++ b/src/cr-sel-eng.c @@ -105,6 +105,10 @@ static xmlNode *get_prev_element_node (xmlNode * a_node); static xmlNode *get_next_parent_element_node (xmlNode * a_node); +/* Quick strcmp. Test only for == 0 or != 0, not < 0 or > 0. */ +#define strqcmp(str,lit,lit_len) \ + (strlen (str) != (lit_len) || memcmp (str, lit, lit_len)) + static gboolean lang_pseudo_class_handler (CRSelEng * a_this, CRAdditionalSel * a_sel, xmlNode * a_node) @@ -120,7 +124,7 @@ lang_pseudo_class_handler (CRSelEng * a_this, && a_sel->content.pseudo->name->stryng && a_node, CR_BAD_PARAM_ERROR); - if (strncmp (a_sel->content.pseudo->name->stryng->str, + if (strqcmp (a_sel->content.pseudo->name->stryng->str, "lang", 4) || !a_sel->content.pseudo->type == FUNCTION_PSEUDO) { cr_utils_trace_info ("This handler is for :lang only"); @@ -134,7 +138,7 @@ lang_pseudo_class_handler (CRSelEng * a_this, for (; node; node = get_next_parent_element_node (node)) { val = xmlGetProp (node, "lang"); if (val - && !strncmp (val, + && !strqcmp (val, a_sel->content.pseudo->extra->stryng->str, a_sel->content.pseudo->extra->stryng->len)) { result = TRUE; @@ -276,7 +280,7 @@ id_add_sel_matches_node (CRAdditionalSel * a_add_sel, xmlNode * a_node) if (xmlHasProp (a_node, "id")) { id = xmlGetProp (a_node, "id"); - if (!strncmp (id, a_add_sel->content.id_name->stryng->str, + if (!strqcmp (id, a_add_sel->content.id_name->stryng->str, a_add_sel->content.id_name->stryng->len)) { result = TRUE; } |