From 64b229d0d6fb3ab4c650fb4bc27618104e79f10c Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Thu, 22 Mar 2007 22:47:24 +0000 Subject: Make attribute handling more spec compliant svn path=/trunk/netsurf/; revision=3215 --- render/box_construct.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/render/box_construct.c b/render/box_construct.c index da03d5449..d034fd546 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -1375,18 +1375,19 @@ bool box_object(BOX_SPECIAL_PARAMS) params->classid = 0; params->params = 0; - /* codebase, classid, and data are URLs (codebase is the base for the - * other two) */ + /* codebase, classid, and data are URLs + * (codebase is the base for the other two) */ if ((codebase = xmlGetProp(n, (const xmlChar *) "codebase"))) { if (!box_extract_link((char *) codebase, - content->data.html.base_url, ¶ms->codebase)) + content->data.html.base_url, + ¶ms->codebase)) return false; xmlFree(codebase); } if (!params->codebase) params->codebase = content->data.html.base_url; - if ((classid = xmlGetProp(n, (const xmlChar *) "codebase"))) { + if ((classid = xmlGetProp(n, (const xmlChar *) "classid"))) { if (!box_extract_link((char *) classid, params->codebase, ¶ms->classid)) return false; @@ -1399,12 +1400,20 @@ bool box_object(BOX_SPECIAL_PARAMS) return false; xmlFree(data); } - if (!params->data) - /* objects without data are ignored */ + + if (!params->classid && !params->data) + /* nothing to embed; ignore */ return true; /* Don't include ourself */ - if (strcmp(content->data.html.base_url, params->data) == 0) + if (params->classid && + strcmp(content->data.html.base_url, + params->classid) == 0) + return true; + + if (params->data && + strcmp(content->data.html.base_url, + params->data) == 0) return true; /* codetype and type are MIME types */ @@ -1412,7 +1421,18 @@ bool box_object(BOX_SPECIAL_PARAMS) return false; if (!box_get_attribute(n, "type", params, ¶ms->type)) return false; - if (params->type && content_lookup(params->type) == CONTENT_OTHER) + + /* classid && !data => classid is used (consult codetype) + * (classid || !classid) && data => data is used (consult type) + * !classid && !data => invalid; ignored */ + + if (params->classid && !params->data && params->codetype && + content_lookup(params->codetype) == CONTENT_OTHER) + /* can't handle this MIME type */ + return true; + + if (params->data && params->type && + content_lookup(params->type) == CONTENT_OTHER) /* can't handle this MIME type */ return true; @@ -1456,8 +1476,9 @@ bool box_object(BOX_SPECIAL_PARAMS) box->object_params = params; /* start fetch (MIME type is ok or not specified) */ - if (!html_fetch_object(content, params->data, box, 0, - content->available_width, 1000, false)) + if (!html_fetch_object(content, + params->data ? params->data : params->classid, + box, 0, content->available_width, 1000, false)) return false; /* convert children and place into fallback */ -- cgit v1.2.3