From 15a37bb9edd0ba7778bf42fbac279fbb72eff2ee Mon Sep 17 00:00:00 2001 From: James Bursa Date: Thu, 2 Oct 2003 11:12:44 +0000 Subject: [project @ 2003-10-02 11:12:44 by bursa] Fix bugs in css_match_rule(). svn path=/import/netsurf/; revision=342 --- css/css.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/css/css.c b/css/css.c index 2030e86c5..892cf9211 100644 --- a/css/css.c +++ b/css/css.c @@ -411,6 +411,8 @@ bool css_match_rule(struct node *rule, xmlNode *element) struct node *detail; xmlNode *anc, *prev; + assert(element->type == XML_ELEMENT_NODE); + if (rule->data && strcasecmp(rule->data, (char *) element->name) != 0) return false; @@ -499,7 +501,8 @@ bool css_match_rule(struct node *rule, xmlNode *element) switch (rule->comb) { case COMB_ANCESTOR: for (anc = element->parent; anc; anc = anc->parent) - if (css_match_rule(rule->right, anc)) + if (anc->type == XML_ELEMENT_NODE && + css_match_rule(rule->right, anc)) return true; break; @@ -514,9 +517,13 @@ bool css_match_rule(struct node *rule, xmlNode *element) break; case COMB_PARENT: - if (!element->parent) + for (anc = element->parent; + anc && anc->type != XML_ELEMENT_NODE; + anc = anc->parent) + ; + if (!anc) return false; - return css_match_rule(rule->right, element->parent); + return css_match_rule(rule->right, anc); break; default: -- cgit v1.2.3