From e93271501092ea328e2163a4d3c4f348e48ca572 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Fri, 11 Jun 2004 12:51:40 +0000 Subject: [project @ 2004-06-11 12:51:40 by jmb] Fix for crash caused by inline style attributes specifying background images. svn path=/import/netsurf/; revision=961 --- css/css.c | 6 ++++-- css/css.h | 3 ++- css/ruleset.c | 8 +++++++- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'css') diff --git a/css/css.c b/css/css.c index 3072c3a47..708e24ad7 100644 --- a/css/css.c +++ b/css/css.c @@ -883,11 +883,13 @@ bool css_match_detail(const struct css_selector *detail, /** * Parse a stand-alone CSS property list. * + * \param c parent content * \param style css_style to update * \param str property list, as found in HTML style attributes */ -void css_parse_property_list(struct css_style * style, char * str) +void css_parse_property_list(struct content *c, struct css_style * style, + char * str) { unsigned char *source_data; unsigned char *current, *end, *token_text; @@ -895,7 +897,7 @@ void css_parse_property_list(struct css_style * style, char * str) unsigned int i; int token; void *parser; - struct css_parser_params param = {true, 0, 0, false, false}; + struct css_parser_params param = {true, c, 0, false, false}; struct css_parser_token token_data; const struct css_parser_token token_start = { "{", 1 }; const struct css_parser_token token_end = { "}", 1 }; diff --git a/css/css.h b/css/css.h index e3ebca02e..c2ff62ef0 100644 --- a/css/css.h +++ b/css/css.h @@ -348,7 +348,8 @@ void css_cascade(struct css_style * const style, const struct css_style * const apply); void css_merge(struct css_style * const style, const struct css_style * const apply); -void css_parse_property_list(struct css_style * style, char * str); +void css_parse_property_list(struct content *c, struct css_style * style, + char * str); colour named_colour(const char *name); void css_dump_style(const struct css_style * const style); void css_dump_stylesheet(const struct css_stylesheet * stylesheet); diff --git a/css/ruleset.c b/css/ruleset.c index 345b86225..a3d43c679 100644 --- a/css/ruleset.c +++ b/css/ruleset.c @@ -539,7 +539,13 @@ void parse_background_image(struct css_style * const s, const struct css_node * else *(t + 1) = 0; - s->background_image.uri = url_join(url, v->stylesheet->url); + /* for inline style attributes, the stylesheet + * content is the parent HTML content + */ + if (v->stylesheet->type == CONTENT_HTML) + s->background_image.uri = url_join(url, v->stylesheet->data.html.base_url); + else + s->background_image.uri = url_join(url, v->stylesheet->url); free(url); if (!s->background_image.uri) return; s->background_image.type = CSS_BACKGROUND_IMAGE_URI; -- cgit v1.2.3