From b41b672fe5228be936715254003132ee21843242 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 22 Nov 2015 09:55:19 +0000 Subject: Hacky fix to prevent attribute fetch on document objects --- javascript/duktape/dukky.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'javascript/duktape/dukky.c') diff --git a/javascript/duktape/dukky.c b/javascript/duktape/dukky.c index b65e94b5a..3549cd5eb 100644 --- a/javascript/duktape/dukky.c +++ b/javascript/duktape/dukky.c @@ -457,6 +457,22 @@ static void dukky_push_handler_code_(duk_context *ctx, dom_string *name, dom_string *onname, *val; dom_element *ele = (dom_element *)et; dom_exception exc; + dom_node_type ntype; + + /* Currently safe since libdom has no event targets which are not + * nodes. Reconsider this as and when we work out how to have + * window do stuff + */ + exc = dom_node_get_node_type(et, &ntype); + if (exc != DOM_NO_ERR) { + duk_push_lstring(ctx, "", 0); + return; + } + + if (ntype != DOM_ELEMENT_NODE) { + duk_push_lstring(ctx, "", 0); + return; + } exc = dom_string_concat(corestring_dom_on, name, &onname); if (exc != DOM_NO_ERR) { @@ -494,6 +510,8 @@ bool dukky_get_current_value_of_event_handler(duk_context *ctx, duk_pop_2(ctx); /* ... node */ dukky_push_handler_code_(ctx, name, et); + /* ... node handlercode? */ + /* TODO: If this is null, clean up and propagate */ /* ... node handlercode */ /** @todo This is entirely wrong, but it's hard to get right */ duk_push_string(ctx, "function (event) {"); -- cgit v1.2.3