From debbugs-submit-bounces@debbugs.gnu.org Mon May 08 06:08:15 2017 Received: (at submit) by debbugs.gnu.org; 8 May 2017 10:08:15 +0000 Received: from localhost ([127.0.0.1]:32961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7faR-0006LZ-4f for submit@debbugs.gnu.org; Mon, 08 May 2017 06:08:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41355) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d7faP-0006LL-2R for submit@debbugs.gnu.org; Mon, 08 May 2017 06:08:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7faI-0004VO-UA for submit@debbugs.gnu.org; Mon, 08 May 2017 06:08:07 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:39445) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d7faI-0004VE-QT for submit@debbugs.gnu.org; Mon, 08 May 2017 06:08:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d7faE-0003td-SZ for bug-gnu-emacs@gnu.org; Mon, 08 May 2017 06:08:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d7faA-0004LZ-Tl for bug-gnu-emacs@gnu.org; Mon, 08 May 2017 06:08:02 -0400 Received: from hapkido.dreamhost.com ([66.33.216.122]:39353) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d7faA-0004Ju-Ln for bug-gnu-emacs@gnu.org; Mon, 08 May 2017 06:07:58 -0400 Received: from homiemail-a37.g.dreamhost.com (homie.mail.dreamhost.com [208.97.132.208]) by hapkido.dreamhost.com (Postfix) with ESMTP id 4D8D389C12 for ; Mon, 8 May 2017 03:07:57 -0700 (PDT) Received: from homiemail-a37.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a37.g.dreamhost.com (Postfix) with ESMTP id 300F5208069 for ; Mon, 8 May 2017 03:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to :subject:date:message-id:mime-version:content-type: content-transfer-encoding; s=jidanni.org; bh=6fO5u0O9mFQ1p3SRlRB ZUNXmz6M=; b=oDBRykJSJqp5Is8FHUxQfawOhvDHY5qSdvJWMwjO5r2NmkbHQ+c +9Hqudcu9gW8Hv6wPsEtgS5s7GFFlnsbf4q5qHhJGogTJlgRO0ZQY41mo9IMT6YI f45QUjVCpM+1OtoEAopsuhSHKt3qcjAASSydGGk/DGbLyrf87OEI/PVM= Received: from jidanni.org (111-246-99-27.dynamic-ip.hinet.net [111.246.99.27]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a37.g.dreamhost.com (Postfix) with ESMTPSA id DC6F8208063 for ; Mon, 8 May 2017 03:07:53 -0700 (PDT) From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson To: bug-gnu-emacs Subject: user trys to copy spam link but ends up contacting spam site Date: Mon, 08 May 2017 18:07:49 +0800 Message-ID: <871srz8xvu.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) "u runs the command shr-copy-url, which is an interactive compiled Lisp function in =E2=80=98shr.el=E2=80=99. Copy the URL under point to the kill ring. If IMAGE-URL (the prefix) is non-nil, or there is no link under point, but there is an image under point then copy the URL of the image under point instead. If called twice, then try to fetch the URL and see whether it redirects somewhere else." The problem with this is the user thinks that u is safe to just copy links. Well a second press (no matter how it happens) ends up telling the spam site 'Yes the user read your spam mail. Send more.' or worse. From debbugs-submit-bounces@debbugs.gnu.org Tue May 09 23:36:38 2017 Received: (at 26826) by debbugs.gnu.org; 10 May 2017 03:36:38 +0000 Received: from localhost ([127.0.0.1]:34851 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8IQY-0005e0-1V for submit@debbugs.gnu.org; Tue, 09 May 2017 23:36:38 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:36050) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8IQV-0005dh-3C; Tue, 09 May 2017 23:36:35 -0400 Received: by mail-it0-f68.google.com with SMTP id n18so2266423itb.3; Tue, 09 May 2017 20:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=40wK2FUVyZfuHvOz/hExXcoAfR8ruG8HbLrvX9eqerU=; b=MUFQYZYAQinHksuI1AyX8OYKwzQm9BL++y0XfuewWkUwdEg6Hm3Sy30QvTE+sckyTc F7HSfIK7B39dJJdyPrhwNEr71wgm1MDv1FjzM896ZTmQeyDQLbPA5sGW8n0+QwSyYB2e SxE1LW+piY+V4G0RjnHC4Y+EAVubMvzq5VlHUF573Wri0/xS+g9vgdO5Ym62m4GETabH XjwlsWnPR74cnKvskNiGg9q927XRlgIJxtiwSkXpI5GPxtXXa8em6OVlKsJCRw7TTz4W +Tkeb9HlT/dyyKhNXb6Tw3Yg9GG9v9MxWCFVzuGdMOpWNlpm2bsHuIbCRD/CmzMJ/zwR 2tug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version :content-transfer-encoding; bh=40wK2FUVyZfuHvOz/hExXcoAfR8ruG8HbLrvX9eqerU=; b=DxClD+XhhPYbzfPSEB/bEVHegHTEUYDUbdq1pqpCAXAHcr9MoO5le8sbi44sCzlYsj bYkqMJhpI3mpy5gPCKqges8JItd9JB7gYfYGiQZZJNvJoUoFaVraCasxrGcDkUZm5W09 ojAGBit3BZUb8N1a/Q6RkkIEuamdAFY1pGR85DqteXxgN3WxVyRvz5Mf3stQtPPG7CNl K1N8j6d1h4mu9aUlqaoTP0B02O2gH8SnTfYNIZvttbjR0YRyuXBC3vHapDtNN1ZR4Zbp tyAzqr28HFRlL1cqVLTkS6c4p45NxHkZu2s1JeJwyxtPGAZod4wTWTD+zUGow1eQ0x62 UtFA== X-Gm-Message-State: AODbwcCy3HH5j/G4tQKM4mXhwQq+8C756AzLqUhkGHJ+sDI9iQB9Dstp BdbEx4zq85MMuA== X-Received: by 10.36.130.129 with SMTP id t123mr3639370itd.31.1494387389421; Tue, 09 May 2017 20:36:29 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id n14sm6261583itg.0.2017.05.09.20.36.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 May 2017 20:36:28 -0700 (PDT) From: npostavs@users.sourceforge.net To: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson Subject: Re: bug#26826: user trys to copy spam link but ends up contacting spam site References: <871srz8xvu.fsf@jidanni.org> Date: Tue, 09 May 2017 23:38:01 -0400 In-Reply-To: <871srz8xvu.fsf@jidanni.org> (=?utf-8?B?IuepjeS4ueWwvA==?= Dan Jacobson"'s message of "Mon, 08 May 2017 18:07:49 +0800") Message-ID: <87k25pjs9y.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 26826 Cc: 26826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) tags 26826 moreinfo quit =E7=A9=8D=E4=B8=B9=E5=B0=BC Dan Jacobson writes: > "u runs the command shr-copy-url, which is an interactive compiled Lisp > function in =E2=80=98shr.el=E2=80=99. > > Copy the URL under point to the kill ring. > If IMAGE-URL (the prefix) is non-nil, or there is no link under > point, but there is an image under point then copy the URL of the > image under point instead. > If called twice, then try to fetch the URL and see whether it > redirects somewhere else." > > The problem with this is the user thinks that u is safe to just copy > links. Well a second press (no matter how it happens) ends up telling > the spam site 'Yes the user read your spam mail. Send more.' or worse. What do you expect Emacs to do differently? From debbugs-submit-bounces@debbugs.gnu.org Wed May 10 02:48:58 2017 Received: (at 26826) by debbugs.gnu.org; 10 May 2017 06:48:58 +0000 Received: from localhost ([127.0.0.1]:34957 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8LQe-0005Os-0U for submit@debbugs.gnu.org; Wed, 10 May 2017 02:48:58 -0400 Received: from homie.mail.dreamhost.com ([208.97.132.208]:48076 helo=homiemail-a99.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8LQc-0005Ok-Av for 26826@debbugs.gnu.org; Wed, 10 May 2017 02:48:54 -0400 Received: from homiemail-a99.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a99.g.dreamhost.com (Postfix) with ESMTP id 54B91D3E06A; Tue, 9 May 2017 23:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=jidanni.org; h=from:to:cc :subject:references:date:message-id:mime-version:content-type; s=jidanni.org; bh=R+zh3vWflHQRHLr/pEXuuVPyTdk=; b=OqPlgter9v/bi JWKZpeMxGuGAffiv89FuutdhJcfG9slowerVPgyYSmFC9qaJOFs8t8juG1Se/hw/ F1D3nAtHi5LmUjG7+9CHJB1pFNSB5WUA49q0kLFZLC/5eRNyVcGHnUvCDfDcwVuS Z56P7JnLZVVFwnyayDLpyUSxGD1yGg= Received: from jidanni.org (111-246-97-173.dynamic-ip.hinet.net [111.246.97.173]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jidanni@jidanni.org) by homiemail-a99.g.dreamhost.com (Postfix) with ESMTPSA id 06DAFD3E068; Tue, 9 May 2017 23:48:49 -0700 (PDT) From: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson To: npostavs@users.sourceforge.net Subject: Re: bug#26826: user trys to copy spam link but ends up contacting spam site References: <871srz8xvu.fsf@jidanni.org> Date: Wed, 10 May 2017 14:48:45 +0800 Message-ID: <877f1pdx6a.fsf@jidanni.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 26826 Cc: 26826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Have the dangerous commands mapped to a different key, not piggybacked on a usually safe key. >>>>> "n" == npostavs writes: n> What do you expect Emacs to do differently? From debbugs-submit-bounces@debbugs.gnu.org Thu May 11 21:13:17 2017 Received: (at 26826) by debbugs.gnu.org; 12 May 2017 01:13:17 +0000 Received: from localhost ([127.0.0.1]:39462 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8z8v-00054o-6v for submit@debbugs.gnu.org; Thu, 11 May 2017 21:13:17 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:35355) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d8z8s-00054T-Cn; Thu, 11 May 2017 21:13:14 -0400 Received: by mail-it0-f66.google.com with SMTP id 67so4708206itx.2; Thu, 11 May 2017 18:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=TXk6VGRXMdi+BgViHKMbOpGfHf3hOGBZw3+PC1SuwYo=; b=U47WhbUS3ZYOOz4azk2Ci5wQK7R3i3ip/Rl6tCfhKvBFL/hulQ4sbkflU9VQiOqj4D 5VHrsvJ5bHe0KWmx4UAEdIUI80br0YKYjKKxIXR8afPw4JByesKtq71m9JH63glXTgKd FPlI/2QpgTzTjcM2tPVDXR1BdinxYdZCEjLneQ5rFO+R9DwL107b2Ca//AuNU7hnFLdQ veGUodwn+xl+LM7X0PW0Q8bgF7ANuCe2RVxb37FDQypqb6aFlMBJM+rShw55icQ6D2xW vGQ7n7kKZkadgLhVyWjOqf2jsQxX60kgV3LxrPhTZGBwT7NkvihZJl5AzPsXNEjpH1uH PTew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=TXk6VGRXMdi+BgViHKMbOpGfHf3hOGBZw3+PC1SuwYo=; b=mP/P3WrBeUtuYWKhumAhqexF9GoUEuk614m7LpkZ6Y9lCAQDdZeIOptXQ0yTfuvc2B ErGAMv986i+qji8P+6if7m+bVNTY3G3MWpkA00DtuNdMxLIkEwB2SFI5EogDxe1mN3qu IiyJYwqWNfoe0zqk+3SrFw640HQMICqkGQPXPBnKC6VfBjMnXe5ORQjVImUajuTwdOeA trP/1GURa/xbf7SP1ZFII6CNTTxiJJVYT0VT3k3AXuWRAjYrV6xMs7aIdxSE3FVFmoSM ZRT8ANoR4acCo5961jCxe730a/wVb1hEL8UVEscS3gwanNiCLv+couFjLI277/Tnk2qc GBxw== X-Gm-Message-State: AODbwcChZPr+jOxN8qHBoco8/OcirQo2w8tm5a1CPPo/c0A7dGdKww7b WVHO6ylWUIENWzKt X-Received: by 10.36.219.4 with SMTP id c4mr1382308itg.49.1494551588916; Thu, 11 May 2017 18:13:08 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id 192sm1913046itl.1.2017.05.11.18.13.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 May 2017 18:13:07 -0700 (PDT) From: npostavs@users.sourceforge.net To: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson Subject: Re: bug#26826: user trys to copy spam link but ends up contacting spam site References: <871srz8xvu.fsf@jidanni.org> <877f1pdx6a.fsf@jidanni.org> Date: Thu, 11 May 2017 21:14:40 -0400 In-Reply-To: <877f1pdx6a.fsf@jidanni.org> (=?utf-8?B?IuepjeS4ueWwvA==?= Dan Jacobson"'s message of "Wed, 10 May 2017 14:48:45 +0800") Message-ID: <877f1mkha7.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 26826 Cc: 26826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable tags 26826 =3D patch quit =E7=A9=8D=E4=B8=B9=E5=B0=BC Dan Jacobson writes: > Have the dangerous commands mapped to a different key, > not piggybacked on a usually safe key. Here's a patch to split out dwim behaviour into separate commands. I'm not sure if we should favour safety or convenience for the default keybindings. Thoughts, anyone? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v1-0001-Split-shr-copy-url-dwim-behavior-into-separate-fu.patch Content-Description: patch >From af9fb0ef26f6624c490d8177599e517ed1799ad5 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Thu, 11 May 2017 19:40:45 -0400 Subject: [PATCH v1] Split shr-copy-url dwim behavior into separate functions (Bug#26826) * lisp/net/shr.el (shr-url-at-point, shr-probe-url) (shr-probe-and-copy-url, shr-maybe-probe-and-copy-url): New functions, split out from `shr-copy-url'. (shr-copy-url): Only copy the url, don't fetch it. (shr-map): Bind 'w' and 'u' to `shr-maybe-probe-and-copy-url', which has the same behavior as the old `shr-copy-url'. --- lisp/net/shr.el | 81 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 6b62a05227..2a9283680c 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -185,8 +185,8 @@ shr-map (define-key map [follow-link] 'mouse-face) (define-key map [mouse-2] 'shr-browse-url) (define-key map "I" 'shr-insert-image) - (define-key map "w" 'shr-copy-url) - (define-key map "u" 'shr-copy-url) + (define-key map "w" 'shr-maybe-probe-and-copy-url) + (define-key map "u" 'shr-maybe-probe-and-copy-url) (define-key map "v" 'shr-browse-url) (define-key map "O" 'shr-save-contents) (define-key map "\r" 'shr-browse-url) @@ -290,43 +290,54 @@ shr--remove-blank-lines-at-the-end (forward-line 1) (delete-region (point) (point-max)))))) -(defun shr-copy-url (&optional image-url) +(defun shr-url-at-point (image-url) + "Return the URL under point as a string. +If IMAGE-URL is non-nil, or there is no link under point, but +there is an image under point then copy the URL of the image +under point instead." + (if image-url + (get-text-property (point) 'image-url) + (or (get-text-property (point) 'shr-url) + (get-text-property (point) 'image-url)))) + +(defun shr-copy-url (url) "Copy the URL under point to the kill ring. If IMAGE-URL (the prefix) is non-nil, or there is no link under point, but there is an image under point then copy the URL of the -image under point instead. -If called twice, then try to fetch the URL and see whether it -redirects somewhere else." +image under point instead." + (interactive (list (shr-url-at-point current-prefix-arg))) + (if (not url) + (message "No URL under point") + (setq url (url-encode-url url)) + (kill-new url) + (message "Copied %s" url))) + +(defun shr-probe-url (url) + "Return URL's redirect destination, if it has one." (interactive "P") - (let ((url (if image-url - (get-text-property (point) 'image-url) - (or (get-text-property (point) 'shr-url) - (get-text-property (point) 'image-url))))) - (cond - ((not url) - (message "No URL under point")) - ;; Resolve redirected URLs. - ((equal url (car kill-ring)) - (url-retrieve - url - (lambda (a) - (when (and (consp a) - (eq (car a) :redirect)) - (with-temp-buffer - (insert (cadr a)) - (goto-char (point-min)) - ;; Remove common tracking junk from the URL. - (when (re-search-forward ".utm_.*" nil t) - (replace-match "" t t)) - (message "Copied %s" (buffer-string)) - (copy-region-as-kill (point-min) (point-max))))) - nil t)) - ;; Copy the URL to the kill ring. - (t - (with-temp-buffer - (insert (url-encode-url url)) - (copy-region-as-kill (point-min) (point-max)) - (message "Copied %s" (buffer-string))))))) + (url-retrieve url + (lambda (a) + (pcase a + (`(:redirect ,destination) + ;; Remove common tracking junk from the URL. + (replace-regexp-in-string ".utm_.*" "" destination)))) + nil t)) + +(defun shr-probe-and-copy-url (url) + "Copy the URL under point to the kill ring. +Like `shr-copy-url', but additionally fetch URL and use its +redirection destination if it has one." + (interactive (list (shr-url-at-point current-prefix-arg))) + (shr-copy-url (or (if url (shr-probe-url url)) url))) + +(defun shr-maybe-probe-and-copy-url (url) + "Copy the URL under point to the kill ring. +If the URL is already at the front of the kill ring act like +`shr-probe-and-copy-url', otherwise like `shr-copy-url'." + (interactive (list (shr-url-at-point current-prefix-arg))) + (if (equal url (car kill-ring)) + (shr-probe-and-copy-url url) + (shr-copy-url url))) (defun shr-next-link () "Skip to the next link." -- 2.11.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 02 23:39:24 2017 Received: (at 26826) by debbugs.gnu.org; 3 Jun 2017 03:39:24 +0000 Received: from localhost ([127.0.0.1]:52260 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGzuN-0006Pd-RM for submit@debbugs.gnu.org; Fri, 02 Jun 2017 23:39:24 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:33236) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGzuL-0006PQ-Pv for 26826@debbugs.gnu.org; Fri, 02 Jun 2017 23:39:22 -0400 Received: by mail-it0-f65.google.com with SMTP id l145so14205877ita.0 for <26826@debbugs.gnu.org>; Fri, 02 Jun 2017 20:39:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=vRIOfFBMES5ya+eKlt5WYoSBOjfKakKTRSIRT+t1Oig=; b=fowGD9tc0TuukFo+bDJfDjhJRC0uCrbQFdgUL/At8odY4gg4Z4VoMPFVGX3mqauPwg 6K7kCQCZW1g/oZ2QmD4NCQpN8xLYjiXB/wda3E8DYjl7RBECiTfPasAb52veMg+iK4EF PELrpMatZj52SnVLiugFn9+qBMs8MCiaEfm9oItiZWobsfHs2BoDjlKzLJCKy6xTCMwD zxmhcMW3vFog21W2KvEmRDpveUcHOFHj7BWZhEFNacka3sGmVxRQY8Qd7cmIuyICPgLt 8yK4A2uVYOfgwCTEnasGbZdnJ+kZy8k0DUcfkeV8m3qfpxlE8wS7xfq8aj4CkUEGKBhd WZ4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=vRIOfFBMES5ya+eKlt5WYoSBOjfKakKTRSIRT+t1Oig=; b=Nm2loLMc8UTvTFNKhMKXN1ExUWPSsS8VlXYCiW7QUap6oUOTplcmA4nKfvFDGk4im+ X+be+9sRXEL+14HCZBdISfPG9r0+6mls6jFn9jF46ApG4OpaMb+vRmjAyF+PQcu6on27 hyOxBfBRwGqGRs1hKTHrUX7m2ewDcOCZMrttvM+Qh5FJHKwOks/IMrCtfY7kELFGl0r2 +v6VhmDo5S0ZWeO+QUId9ZEimp9ML/2TimDHRRi67zlWPmab2gYgSwLp2BslwQGMDuc3 D+OiNO4Tq3tWNh1Z5P1WGFR6gR0pxOUERrV6MEiA84TTjfOE3ddtqneCKshtqGlPwE+0 9uMA== X-Gm-Message-State: AODbwcCwr5gg1ZOC1qw6ZES4pczc8TtoxUJqOLj2wWznztLKsAhEZQ/+ 4rNjktlOfNNIXdjX X-Received: by 10.36.44.201 with SMTP id i192mr2595227iti.21.1496461156114; Fri, 02 Jun 2017 20:39:16 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id f19sm10910222ioe.1.2017.06.02.20.39.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Jun 2017 20:39:15 -0700 (PDT) From: npostavs@users.sourceforge.net To: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson Subject: Re: bug#26826: user trys to copy spam link but ends up contacting spam site References: <871srz8xvu.fsf@jidanni.org> <877f1pdx6a.fsf@jidanni.org> <877f1mkha7.fsf@users.sourceforge.net> Date: Fri, 02 Jun 2017 23:40:53 -0400 In-Reply-To: <877f1mkha7.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Thu, 11 May 2017 21:14:40 -0400") Message-ID: <87inkd20xm.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 26826 Cc: 26826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) --=-=-= Content-Type: text/plain npostavs@users.sourceforge.net writes: > Here's a patch to split out dwim behaviour into separate commands. I'm > not sure if we should favour safety or convenience for the default > keybindings. Here's a non-broken version of that: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=v2-0001-Split-shr-copy-url-dwim-behavior-into-separate-fu.patch Content-Description: patch >From 7d3f680e204d8525f4d518777f7ace76ce000192 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Thu, 11 May 2017 19:40:45 -0400 Subject: [PATCH v2] Split shr-copy-url dwim behavior into separate functions (Bug#26826) * lisp/net/shr.el (shr-url-at-point, shr-probe-url) (shr-probe-and-copy-url, shr-maybe-probe-and-copy-url): New functions, split out from `shr-copy-url'. (shr-copy-url): Only copy the url, don't fetch it. (shr-map): Bind 'w' and 'u' to `shr-maybe-probe-and-copy-url', which has the same behavior as the old `shr-copy-url'. --- lisp/net/shr.el | 85 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 2a6b3960c4..749d250022 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -185,8 +185,8 @@ (defvar shr-map (define-key map [follow-link] 'mouse-face) (define-key map [mouse-2] 'shr-browse-url) (define-key map "I" 'shr-insert-image) - (define-key map "w" 'shr-copy-url) - (define-key map "u" 'shr-copy-url) + (define-key map "w" 'shr-maybe-probe-and-copy-url) + (define-key map "u" 'shr-maybe-probe-and-copy-url) (define-key map "v" 'shr-browse-url) (define-key map "O" 'shr-save-contents) (define-key map "\r" 'shr-browse-url) @@ -290,43 +290,58 @@ (defun shr--remove-blank-lines-at-the-end (start end) (forward-line 1) (delete-region (point) (point-max)))))) -(defun shr-copy-url (&optional image-url) +(defun shr-url-at-point (image-url) + "Return the URL under point as a string. +If IMAGE-URL is non-nil, or there is no link under point, but +there is an image under point then copy the URL of the image +under point instead." + (if image-url + (get-text-property (point) 'image-url) + (or (get-text-property (point) 'shr-url) + (get-text-property (point) 'image-url)))) + +(defun shr-copy-url (url) "Copy the URL under point to the kill ring. If IMAGE-URL (the prefix) is non-nil, or there is no link under point, but there is an image under point then copy the URL of the -image under point instead. -If called twice, then try to fetch the URL and see whether it -redirects somewhere else." +image under point instead." + (interactive (list (shr-url-at-point current-prefix-arg))) + (if (not url) + (message "No URL under point") + (setq url (url-encode-url url)) + (kill-new url) + (message "Copied %s" url))) + +(defun shr-probe-url (url cont) + "Pass URL's redirect destination to CONT, if it has one. +CONT should be a function of one argument. If URL is not +redirected, then CONT is never called." (interactive "P") - (let ((url (if image-url - (get-text-property (point) 'image-url) - (or (get-text-property (point) 'shr-url) - (get-text-property (point) 'image-url))))) - (cond - ((not url) - (message "No URL under point")) - ;; Resolve redirected URLs. - ((equal url (car kill-ring)) - (url-retrieve - url - (lambda (a) - (when (and (consp a) - (eq (car a) :redirect)) - (with-temp-buffer - (insert (cadr a)) - (goto-char (point-min)) - ;; Remove common tracking junk from the URL. - (when (re-search-forward ".utm_.*" nil t) - (replace-match "" t t)) - (message "Copied %s" (buffer-string)) - (copy-region-as-kill (point-min) (point-max))))) - nil t)) - ;; Copy the URL to the kill ring. - (t - (with-temp-buffer - (insert (url-encode-url url)) - (copy-region-as-kill (point-min) (point-max)) - (message "Copied %s" (buffer-string))))))) + (url-retrieve + url (lambda (a) + (pcase a + (`(:redirect ,destination . ,_) + ;; Remove common tracking junk from the URL. + (funcall cont (replace-regexp-in-string + ".utm_.*" "" destination))))) + nil t)) + +(defun shr-probe-and-copy-url (url) + "Copy the URL under point to the kill ring. +Like `shr-copy-url', but additionally fetch URL and use its +redirection destination if it has one." + (interactive (list (shr-url-at-point current-prefix-arg))) + (if url (shr-probe-url url #'shr-copy-url) + (shr-copy-url url))) + +(defun shr-maybe-probe-and-copy-url (url) + "Copy the URL under point to the kill ring. +If the URL is already at the front of the kill ring act like +`shr-probe-and-copy-url', otherwise like `shr-copy-url'." + (interactive (list (shr-url-at-point current-prefix-arg))) + (if (equal url (car kill-ring)) + (shr-probe-and-copy-url url) + (shr-copy-url url))) (defun shr-next-link () "Skip to the next link." -- 2.11.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 02 16:22:51 2017 Received: (at 26826) by debbugs.gnu.org; 2 Jul 2017 20:22:51 +0000 Received: from localhost ([127.0.0.1]:49096 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRlOM-0005rp-Tj for submit@debbugs.gnu.org; Sun, 02 Jul 2017 16:22:51 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:34405) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRlOL-0005rX-6f; Sun, 02 Jul 2017 16:22:49 -0400 Received: by mail-it0-f66.google.com with SMTP id o202so7547473itc.1; Sun, 02 Jul 2017 13:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=Ge/3mkZQ6QmFLHb6tF+lSEMwgSYcH13pFCXRGDojzJ0=; b=ALEHhD9dpcNinR//kVL9hUP07Zci46X45Pou1QccPmTXtjgm6kXVP8vAHkDbK5c33v 0eRbI91SWwoH7HFaafX7CjNSG+3SFb5SyGrrSR0ZQ4f+w+PF+HG1OR9KdGrccDCVcck5 KyJ5B/dRnKSFl0ESFsKbYy4GTVsoGh5gYd6GuJv6UMSabdMlr38An0SzC5JtuaANrkCk 49XVzGQXczeRpTrKvVt9xcimQ7yZ2oNbRAxnB5JphRB3Aysgdnaxnt2rAkkW9CYkbfjf HJEbaXGBtu4hHUKSAbC+HsN421HzWaDeCkHP1NLMxcHozqASx01WQaIzz36yyVDvk7jj G08w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=Ge/3mkZQ6QmFLHb6tF+lSEMwgSYcH13pFCXRGDojzJ0=; b=BhU0GHet2Q62fZSAAyG0GhbdaQL+DKeVcbypk5r8gJkNeMK4xp9m/mQ/HdYVifnyO1 WJamuOC/dzNxPpc2DcOnIk9f2Ip9/LfH+n2VTvfxs7bxsHnXUPSUBJU4N+RoAZEkuHnw UYp1mcfKmFsb6eyxDHS0KvTR49Bif7AwJ3zFXq9LLe9K8T2rFyDz6paLqaI9J87wmanz yjxHZNIrUhDRoFb05ar72MaL0DAAjJCa9fK6Apcd9nCx5vIdJuPpNTp4jiWrZRte13TS dj+42QP34PbcBCWQweqkIrdXJiPoLJAVgqw3FxkQP5BuowRsqegff97Q9TEW7YF/qB2Q eicA== X-Gm-Message-State: AIVw111o2yOHfrDF4Yq99mNgBYBRRkDGvEnxPeZo8LMJFjKVd/VQ/HIV XczIzADAdKBmUwJ4 X-Received: by 10.36.37.210 with SMTP id g201mr4848099itg.100.1499026963464; Sun, 02 Jul 2017 13:22:43 -0700 (PDT) Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id w65sm9201405ita.21.2017.07.02.13.22.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 02 Jul 2017 13:22:42 -0700 (PDT) From: npostavs@users.sourceforge.net To: =?utf-8?B?56mN5Li55bC8?= Dan Jacobson Subject: Re: bug#26826: user trys to copy spam link but ends up contacting spam site References: <871srz8xvu.fsf@jidanni.org> <877f1pdx6a.fsf@jidanni.org> <877f1mkha7.fsf@users.sourceforge.net> <87inkd20xm.fsf@users.sourceforge.net> Date: Sun, 02 Jul 2017 16:24:19 -0400 In-Reply-To: <87inkd20xm.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net's message of "Fri, 02 Jun 2017 23:40:53 -0400") Message-ID: <87mv8mk2oc.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 26826 Cc: 26826@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) tags 26826 fixed close 26826 26.1 quit npostavs@users.sourceforge.net writes: > npostavs@users.sourceforge.net writes: > >> Here's a patch to split out dwim behaviour into separate commands. I'm >> not sure if we should favour safety or convenience for the default >> keybindings. > > Here's a non-broken version of that: Pushed to master [1: 1b4f0a92ff]. [1: 1b4f0a92ff]: 2017-07-02 16:19:58 -0400 Split shr-copy-url dwim behavior into separate functions (Bug#26826) http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=1b4f0a92ff3505ef9a465b9b391756e3a73a6443 From unknown Thu Aug 14 22:19:46 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 31 Jul 2017 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator