summaryrefslogtreecommitdiff
path: root/javascript/duktape
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2015-11-22 09:55:19 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2015-11-22 09:55:19 +0000
commitb41b672fe5228be936715254003132ee21843242 (patch)
tree4b334eef6fd4f85832169192abe41f04de9494fc /javascript/duktape
parentf7ebec7142321c0d97789015d8185c5b0cacda0c (diff)
downloadnetsurf-b41b672fe5228be936715254003132ee21843242.tar.gz
netsurf-b41b672fe5228be936715254003132ee21843242.tar.bz2
Hacky fix to prevent attribute fetch on document objects
Diffstat (limited to 'javascript/duktape')
-rw-r--r--javascript/duktape/dukky.c18
1 files changed, 18 insertions, 0 deletions
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) {");