diff options
| author | NoƩ Lopez | 2024-01-19 23:40:53 +0100 |
|---|---|---|
| committer | Eli Zaretskii | 2024-03-14 11:17:24 +0200 |
| commit | f6a27bc32d19727dfcbee65fb9894b53aec46c65 (patch) | |
| tree | 63cfd181341aa4f9030d237b9bffff07b9970796 | |
| parent | 013114664ef4923872ffad26a97f4d314c9a84bf (diff) | |
| download | emacs-f6a27bc32d19727dfcbee65fb9894b53aec46c65.tar.gz emacs-f6a27bc32d19727dfcbee65fb9894b53aec46c65.zip | |
Add user option to disable JavaScript in xwidget webview
* src/xwidget.c: Add the 'xwidget-webkit-disable-javascript'
variable to disable JavaScript in WebKit sessions. (Bug#68604)
* etc/NEWS:
* doc/emacs/misc.texi (Embedded Webkit Widgets): Document
the change.
| -rw-r--r-- | doc/emacs/misc.texi | 8 | ||||
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/xwidget.el | 7 | ||||
| -rw-r--r-- | src/xwidget.c | 8 |
4 files changed, 28 insertions, 1 deletions
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index 7eb28f56826..bfc86e3c9d4 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi | |||
| @@ -3009,6 +3009,14 @@ buffer, and lets you navigate to those pages by hitting @kbd{RET}. | |||
| 3009 | 3009 | ||
| 3010 | It is bound to @kbd{H}. | 3010 | It is bound to @kbd{H}. |
| 3011 | 3011 | ||
| 3012 | @vindex xwidget-webkit-disable-javascript | ||
| 3013 | @cindex disabling javascript in webkit buffers | ||
| 3014 | JavaScript is enabled by default inside WebKit buffers, this can be | ||
| 3015 | undesirable as websites often use it to track your online activity. It | ||
| 3016 | can be disabled by setting the variable @code{xwidget-webkit-disable-javascript} to @code{t}. | ||
| 3017 | You must kill all WebKit buffers for this setting to take effect after | ||
| 3018 | it is changed. | ||
| 3019 | |||
| 3012 | @node Browse-URL | 3020 | @node Browse-URL |
| 3013 | @subsection Following URLs | 3021 | @subsection Following URLs |
| 3014 | @cindex World Wide Web | 3022 | @cindex World Wide Web |
| @@ -1437,6 +1437,12 @@ This allows the user to customize the key selection method, which can be | |||
| 1437 | either by using a pop-up buffer or from the minibuffer. The pop-up | 1437 | either by using a pop-up buffer or from the minibuffer. The pop-up |
| 1438 | buffer method is the default, which preserves previous behavior. | 1438 | buffer method is the default, which preserves previous behavior. |
| 1439 | 1439 | ||
| 1440 | ** Xwidget Webkit | ||
| 1441 | |||
| 1442 | +++ | ||
| 1443 | *** New user option 'xwidget-webkit-disable-javascript'. | ||
| 1444 | This allows disabling JavaScript in xwidget Webkit sessions. | ||
| 1445 | |||
| 1440 | 1446 | ||
| 1441 | * New Modes and Packages in Emacs 30.1 | 1447 | * New Modes and Packages in Emacs 30.1 |
| 1442 | 1448 | ||
diff --git a/lisp/xwidget.el b/lisp/xwidget.el index cca01c8cb3a..2fb79bb7b1d 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el | |||
| @@ -116,6 +116,13 @@ buffers for this setting to take effect after setting it to nil." | |||
| 116 | :type '(choice (const :tag "Do not store cookies" nil) file) | 116 | :type '(choice (const :tag "Do not store cookies" nil) file) |
| 117 | :version "29.1") | 117 | :version "29.1") |
| 118 | 118 | ||
| 119 | (defcustom xwidget-webkit-disable-javascript nil | ||
| 120 | "If non-nil, disables the execution of JavaScript in xwidget webkit sessions. | ||
| 121 | You must kill all xwidget-webkit buffers for this setting to take | ||
| 122 | effect after changing it." | ||
| 123 | :type '(boolean) | ||
| 124 | :version "30.0") | ||
| 125 | |||
| 119 | ;;;###autoload | 126 | ;;;###autoload |
| 120 | (defun xwidget-webkit-browse-url (url &optional new-session) | 127 | (defun xwidget-webkit-browse-url (url &optional new-session) |
| 121 | "Ask xwidget-webkit to browse URL. | 128 | "Ask xwidget-webkit to browse URL. |
diff --git a/src/xwidget.c b/src/xwidget.c index 58910459142..5b82ef6e840 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 22 | #include "buffer.h" | 22 | #include "buffer.h" |
| 23 | #include "coding.h" | 23 | #include "coding.h" |
| 24 | #include "xwidget.h" | 24 | #include "xwidget.h" |
| 25 | |||
| 26 | #include "lisp.h" | 25 | #include "lisp.h" |
| 27 | #include "blockinput.h" | 26 | #include "blockinput.h" |
| 28 | #include "dispextern.h" | 27 | #include "dispextern.h" |
| @@ -379,6 +378,7 @@ fails. */) | |||
| 379 | /* Enable the developer extras. */ | 378 | /* Enable the developer extras. */ |
| 380 | settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (xw->widget_osr)); | 379 | settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (xw->widget_osr)); |
| 381 | g_object_set (G_OBJECT (settings), "enable-developer-extras", TRUE, NULL); | 380 | g_object_set (G_OBJECT (settings), "enable-developer-extras", TRUE, NULL); |
| 381 | g_object_set (G_OBJECT (settings), "enable-javascript", !xwidget_webkit_disable_javascript, NULL); | ||
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, | 384 | gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width, |
| @@ -3972,6 +3972,12 @@ syms_of_xwidget (void) | |||
| 3972 | doc: /* List of all xwidget views. */); | 3972 | doc: /* List of all xwidget views. */); |
| 3973 | Vxwidget_view_list = Qnil; | 3973 | Vxwidget_view_list = Qnil; |
| 3974 | 3974 | ||
| 3975 | DEFVAR_BOOL("xwidget-webkit-disable-javascript", xwidget_webkit_disable_javascript, | ||
| 3976 | doc: /* If non-nil, disables the execution of JavaScript in xwidget webkit sessions. | ||
| 3977 | You must kill all xwidget-webkit buffers for this setting to take | ||
| 3978 | effect after changing it. */); | ||
| 3979 | xwidget_webkit_disable_javascript = false; | ||
| 3980 | |||
| 3975 | Fprovide (intern ("xwidget-internal"), Qnil); | 3981 | Fprovide (intern ("xwidget-internal"), Qnil); |
| 3976 | 3982 | ||
| 3977 | id_to_xwidget_map = CALLN (Fmake_hash_table, QCtest, Qeq, | 3983 | id_to_xwidget_map = CALLN (Fmake_hash_table, QCtest, Qeq, |