mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-21 03:32:35 +03:00
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.
This commit is contained in:
parent
3dcf7d80a1
commit
594012ef52
@ -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, '\'');
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user