From 85ec83636d60fe945bc3df00cb20d9a850ce7ae8 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Tue, 23 Aug 2011 19:59:13 +0000 Subject: Reject attempts by a stylesheet to import itself svn path=/trunk/netsurf/; revision=12644 --- css/css.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'css/css.c') diff --git a/css/css.c b/css/css.c index 79eda90b8..9d0014ec6 100644 --- a/css/css.c +++ b/css/css.c @@ -587,13 +587,22 @@ css_error nscss_handle_import(void *pw, css_stylesheet *parent, /* Create content */ c->imports[c->import_count].media = media; - nerror = hlcache_handle_retrieve(lwc_string_data(url), - 0, referer, NULL, nscss_import, ctx, - &child, accept, - &c->imports[c->import_count].c); - if (nerror != NSERROR_OK) { + + /* Avoid importing ourself */ + if (strcmp(lwc_string_data(url), referer) == 0) { + c->imports[c->import_count].c = NULL; + /* No longer require context as we're not fetching anything */ free(ctx); - return CSS_NOMEM; + ctx = NULL; + } else { + nerror = hlcache_handle_retrieve(lwc_string_data(url), + 0, referer, NULL, nscss_import, ctx, + &child, accept, + &c->imports[c->import_count].c); + if (nerror != NSERROR_OK) { + free(ctx); + return CSS_NOMEM; + } } #ifdef NSCSS_IMPORT_TRACE -- cgit v1.2.3