From 594012ef52a6237995d1100d1a3315470b191cbe Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 21 Jan 2016 14:11:36 +0000 Subject: Ensure constant javascript_enabled for HTML contents. Now we take the value of the javascript_enabled option when the content is created. We then use the content's script_enabled boolean everywhere else. This prevents us getting inconsistent values for javascript_enabled if a user toggles the setting while a page is loading. It was read frequently during box construction, and also the parser's script enabled setting could change where we handled a change of encoding. Now we only care about the setting of the javascript_enabled option at time of html_content creation. --- render/box_construct.c | 4 ++-- render/html.c | 5 +++-- render/html_internal.h | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'render') diff --git a/render/box_construct.c b/render/box_construct.c index ad39684a1..6a363166f 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -1627,7 +1627,7 @@ bool box_image(BOX_SPECIAL_PARAMS) bool box_noscript(BOX_SPECIAL_PARAMS) { /* If scripting is enabled, do not display the contents of noscript */ - if (nsoption_bool(enable_javascript)) + if (content->enable_scripting) *convert_children = false; return true; @@ -3025,7 +3025,7 @@ bool box_extract_link(const html_content *content, } s[j] = 0; - if (nsoption_bool(enable_javascript) == false) { + if (content->enable_scripting == false) { /* extract first quoted string out of "javascript:" link */ if (strncmp(s, "javascript:", 11) == 0) { apos0 = strchr(s, '\''); diff --git a/render/html.c b/render/html.c index a21901775..06e2e0673 100644 --- a/render/html.c +++ b/render/html.c @@ -850,6 +850,7 @@ html_create_html_data(html_content *c, const http_parameter *params) c->scripts = NULL; c->jscontext = NULL; + c->enable_scripting = nsoption_bool(enable_javascript); c->base.active = 1; /* The html content itself is active */ if (lwc_intern_string("*", SLEN("*"), &c->universal) != lwc_error_ok) { @@ -876,7 +877,7 @@ html_create_html_data(html_content *c, const http_parameter *params) /* Create the parser binding */ parse_params.enc = c->encoding; parse_params.fix_enc = true; - parse_params.enable_script = nsoption_bool(enable_javascript); + parse_params.enable_script = c->enable_scripting; parse_params.msg = NULL; parse_params.script = html_process_script; parse_params.ctx = c; @@ -1019,7 +1020,7 @@ html_process_encoding_change(struct content *c, parse_params.enc = html->encoding; parse_params.fix_enc = true; - parse_params.enable_script = nsoption_bool(enable_javascript); + parse_params.enable_script = html->enable_scripting; parse_params.msg = NULL; parse_params.script = html_process_script; parse_params.ctx = html; diff --git a/render/html_internal.h b/render/html_internal.h index e5740dbda..aaecb7823 100644 --- a/render/html_internal.h +++ b/render/html_internal.h @@ -97,6 +97,9 @@ typedef struct html_content { /** Whether a layout (reflow) is in progress */ bool reflowing; + /** Whether scripts are enabled for this content */ + bool enable_scripting; + /* Title element node */ dom_node *title; -- cgit v1.2.3