From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eshel Yaron 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: Thu, 07 Nov 2024 09:42:29 +0100 Message-ID: References: <20241106005544.26516-1-me@fabionatali.com> <86pln8sfqe.fsf@gnu.org> <87ikt0gz7b.fsf@fabionatali.com> Reply-To: Eshel Yaron Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18924"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 74218@debbugs.gnu.org, Eli Zaretskii , Fabio Natali To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 07 09:43:14 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 1t8y6k-0004nD-Ij for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 07 Nov 2024 09:43:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8y6b-0008OF-16; Thu, 07 Nov 2024 03:43:05 -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 1t8y6Y-0008O2-TR for bug-gnu-emacs@gnu.org; Thu, 07 Nov 2024 03:43:02 -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 1t8y6Y-0000QX-L3 for bug-gnu-emacs@gnu.org; Thu, 07 Nov 2024 03:43:02 -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:References:In-Reply-To:From:To:Subject; bh=nZ6H2SElJ3VU4r0g/Ss9Z6K4rrazvonpd5U9kUXias4=; b=YHh9ALvc9+pRU2dV/tCxUq0Q/K7LFsZ5Z1Q9VsUmuq63ZeZ3kfyBeAqIgr95Aqwq5sMECU22taYtfdFAF8VOhXOwENNv/q0vBaHZkTtv+9smv0Zj0/qFY5mo1bVO6gL1HHWsS+JFX/puzDv/StAF4WKXnDTRxcDa4hi0Ro8DePs+53Ys+QjHZuvzxDBwg/JmzEQ/46iacK9iR//+yLlKwLTVHadSdRVSbIFfxp0biUZas9Gfh7CEoDO/wKVuqh2I++fxsibVUqq6OX7C1M1jyFpya/oVOV+ni8HE2k1I73wdct3valgz1Wb9XdxqhECzTmqJp6ik/ZAHlsfxgr6vvQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t8y6Y-0003ZC-Fw for bug-gnu-emacs@gnu.org; Thu, 07 Nov 2024 03:43:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Nov 2024 08:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74218 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74218-submit@debbugs.gnu.org id=B74218.173096895613675 (code B ref 74218); Thu, 07 Nov 2024 08:43:02 +0000 Original-Received: (at 74218) by debbugs.gnu.org; 7 Nov 2024 08:42:36 +0000 Original-Received: from localhost ([127.0.0.1]:47084 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t8y67-0003YV-Iw for submit@debbugs.gnu.org; Thu, 07 Nov 2024 03:42:36 -0500 Original-Received: from mail.eshelyaron.com ([107.175.124.16]:52000 helo=eshelyaron.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t8y64-0003YM-O9 for 74218@debbugs.gnu.org; Thu, 07 Nov 2024 03:42:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1730968952; bh=FDTBX8K5JJf0XNJvhzzPrcaMPfgjbixBZgz/AQz06tc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=vpYIp1UtYLv77lhwZ2/Tz0wraPm09ZyUj5Mf1I57r2JVe36sq5bMzCmoDqjrIzxd1 44jchp29g7+gvUH8s14Hr16a1LaSFkIqOurfnYCqL+HzY0n73NxsgDiGUK36Pk6Kwa 7tIUFh/BrvljtXcBsjSjYYFHNXcEKeo1wOZUi5ne5SVGO65fZeMKl8Ep4wE1zB/1xw aBKW/oqHGrfxPB2OB+r2nPNKbOW201Xeeoo+rf5iF8z3Gij2KAc0vYa1MtylB5tYLb FVGcDFuVAgMF2F+W/ufmg8TxMYR1VuhXKkgnF0TIxNfegXQnn3xtJdm8khNn56PxO6 CwDlReA8U3Fog== In-Reply-To: (Stefan Kangas's message of "Wed, 6 Nov 2024 17:51:22 -0800") 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:295000 Archived-At: Hi, Stefan Kangas writes: > Fabio Natali writes: > >> From cdd17053befac8298a04d0cdfc4cafe5a410166b Mon Sep 17 00:00:00 2001 >> From: Fabio Natali >> Date: Tue, 5 Nov 2024 23:52:30 +0000 >> Subject: [PATCH v2] Ask confirmation before sending region to search engine >> >> 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. > > This is a good addition, thanks. I too agree that it's a good idea to optionally require confirmation. However, I suspect that a yes/no question is not the best interface in this case. Instead, it's better to simply prepopulate the minibuffer with the contents of the region. Then you confirm with RET and cancel with C-g. In addition, this lets you examine and edit your input. Namely, we can implement eww-search-words along the following lines: --8<---------------cut here---------------start------------->8--- (defun eww-search-words () "..." (interactive) (eww (eww-read-url-or-search-string (and (use-region-p) (string-trim (buffer-substring-no-properties (point) (mark))))))) --8<---------------cut here---------------end--------------->8--- Where eww-read-url-or-search-string is a new function extracted from the interactive spec of eww: --8<---------------cut here---------------start------------->8--- (defun eww-read-url-or-search-string (&optional initial-input) (let ((uris (eww-suggested-uris))) (completing-read (format-prompt "Enter URL or keywords" uris) (seq-uniq (append eww-prompt-history uris)) nil nil initial-input 'eww-prompt-history uris))) --8<---------------cut here---------------end--------------->8--- Just my 2c, Eshel