From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Fabio Natali via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74218: [PATCH] Ask confirmation before sending region to search engine. Date: Wed, 6 Nov 2024 00:46:46 +0000 Message-ID: <20241106005544.26516-1-me@fabionatali.com> Reply-To: Fabio Natali Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="337"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Fabio Natali To: 74218@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 06 01:57:42 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t8UMg-000ATi-8M for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 06 Nov 2024 01:57:42 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8UMK-0001va-2a; Tue, 05 Nov 2024 19:57:20 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8UMH-0001t8-7e for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2024 19:57:17 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t8UM3-00052J-91 for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2024 19:57:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=tIINFY529tJCvhAgX9D95hitdRwmU3or7KrqIaspDQA=; b=WuCChSUeyOK9EVjREvMY/1YJly7pF/Xm5Ek/SzEZrDW3GL5EQQ2rL7tDqNBeK845wM+WYOAWG4MEcrUJC8WBJxuj7vxCSREYMjWW5e8f0oxupSalUcuqAU7sRX+8gKS0KPDqQ1o6SBqQzTUKZCbcdu4ZnpSuU+FhWBkJpOjc40ivYjHRViBLpTdjdqu77rNHfS/nhiMj4byNr82gvwFzYhZ94l3MIWiiMOkDO1HwIQhbVyg8mcE/y+OOSqY/D6LRkYFrdvCQqJkDmMrqkWLpRGLundineTxmAYgNTpxn8Syc1VupFqgTgGcBN3+xZiyH39c67jEaHNh/Fuee1t/NOw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t8UM2-0000A8-Gb for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2024 19:57:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Fabio Natali Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Nov 2024 00:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74218 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1730854568553 (code B ref -1); Wed, 06 Nov 2024 00:57:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Nov 2024 00:56:08 +0000 Original-Received: from localhost ([127.0.0.1]:38608 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t8ULA-00008r-94 for submit@debbugs.gnu.org; Tue, 05 Nov 2024 19:56:08 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:52412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t8UL8-00008j-3m for submit@debbugs.gnu.org; Tue, 05 Nov 2024 19:56:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8UL6-0001j1-Az for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2024 19:56:04 -0500 Original-Received: from relay1-d.mail.gandi.net ([2001:4b98:dc4:8::221]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8UL2-0004ye-BS for bug-gnu-emacs@gnu.org; Tue, 05 Nov 2024 19:56:04 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 6950A240002; Wed, 6 Nov 2024 00:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fabionatali.com; s=gm1; t=1730854554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=tIINFY529tJCvhAgX9D95hitdRwmU3or7KrqIaspDQA=; b=MMlomVYoiD2HWqjflZHuXXtFLpjGiZQJTtP/8p2XeOWVwsKjk6W31i4cRWegmjqtK71k88 jEqVanUYvxVsv7AZJiNzHa/k5OCyHDDpA25oC8aPib307Pt/AtDwCOexuzE/gC8oAEOJjr caKOAw8UPeYmHz8GMQsFJmRpDgCkyPa0R5PXLVoOZtmSJdGXC1q430fZKNbpYr0t++wyYq YyvnEIRKZBzhOBYuqwFhLw/6/ZJ8nlBf0GAYGgQiTQtaZuNVy8hc8GJV21S2KmONgyT1BZ MNbgYVCDn2xOwAp3yuM8hOMXkYJ/6ULbvnQjEbDuci4Cv0vNZTYWSYueWI6qug== X-Mailer: git-send-email 2.46.0 X-GND-Sasl: me@fabionatali.com Received-SPF: pass client-ip=2001:4b98:dc4:8::221; envelope-from=me@fabionatali.com; helo=relay1-d.mail.gandi.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:294926 Archived-At: * lisp/net/eww.el (eww-search-confirm-send-region, eww-search-words): With 'eww-search-words' (by default bound to 'M-s M-w') a user can type in some search terms and get back the results of a web search from a predefined search engine. If a region is selected, 'eww-search-words' will use that for the web search instead of prompting the user. In its current form, 'eww-search-words' presents a security and usability problem. It is relatively too easy to mistakenly launch the function and, if a region of text is selected, have potentially sensitive data sent out to a third-party service. This commit changes the search function's default behaviour so that explicit confirmation is required before a region is sent to a search engine. The behaviour can be adjusted via the newly-introduced 'eww-search-confirm-send-region' variable, which is set to true by default. --- Hiya, This is to change the default behaviour of the 'eww-search-words' function. The provided commit message provides some context around why I think the change is necessary. I tentatively marked 'eww-search-confirm-send-region' as introduced in 30.0. Let me know if and when you think it makes sense to merge this and therefore whether 30.0 should be changed to any later number. I hope the commit looks alright but should any change be needed, please just let me know. This is my first commit to Emacs - any feedback is more than welcome! Thanks, best wishes, Fabio. lisp/net/eww.el | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 2d351dff88f..8f503757f68 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -52,6 +52,15 @@ :group 'eww :type 'string) +(defcustom eww-search-confirm-send-region t + "Non-nil if Emacs should confirm sending the selected region to +the configured search engine. This is the default to mitigate the +risk of accidental data leak. Set this variable to nil to send +the region to the search engine straightaway." + :version "30.0" + :group 'eww + :type 'boolean) + (defcustom eww-search-prefix "https://duckduckgo.com/html/?q=" "Prefix URL to search engine." :version "24.4" @@ -603,10 +612,15 @@ user for a search string. See the variable `eww-search-prefix' for the search engine used." (interactive) (if (use-region-p) - (let ((region-string (buffer-substring (region-beginning) (region-end)))) - (if (not (string-match-p "\\`[ \n\t\r\v\f]*\\'" region-string)) - (eww region-string) - (call-interactively #'eww))) + (when (or (not eww-search-confirm-send-region) + (yes-or-no-p + (format-message + "Send region to the configured search engine? "))) + (let ((region-string (buffer-substring (region-beginning) + (region-end)))) + (if (not (string-match-p "\\`[ \n\t\r\v\f]*\\'" region-string)) + (eww region-string) + (call-interactively #'eww)))) (call-interactively #'eww))) (defun eww--open-url-in-new-buffer (url) -- 2.46.0