GNU bug report logs -
#26826
user trys to copy spam link but ends up contacting spam site
Previous Next
Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Date: Mon, 8 May 2017 10:09:02 UTC
Severity: minor
Tags: fixed, patch
Fixed in version 26.1
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 26826 in the body.
You can then email your comments to 26826 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#26826
; Package
emacs
.
(Mon, 08 May 2017 10:09:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 08 May 2017 10:09:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
"u runs the command shr-copy-url, which is an interactive compiled Lisp
function in ‘shr.el’.
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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#26826
; Package
emacs
.
(Wed, 10 May 2017 03:37:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 26826 <at> debbugs.gnu.org (full text, mbox):
tags 26826 moreinfo
quit
積丹尼 Dan Jacobson <jidanni <at> jidanni.org> writes:
> "u runs the command shr-copy-url, which is an interactive compiled Lisp
> function in ‘shr.el’.
>
> 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?
Added tag(s) moreinfo.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Wed, 10 May 2017 03:37:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#26826
; Package
emacs
.
(Wed, 10 May 2017 06:49:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 26826 <at> debbugs.gnu.org (full text, mbox):
Have the dangerous commands mapped to a different key,
not piggybacked on a usually safe key.
>>>>> "n" == npostavs <npostavs <at> users.sourceforge.net> writes:
n> What do you expect Emacs to do differently?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#26826
; Package
emacs
.
(Fri, 12 May 2017 01:14:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 26826 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 26826 = patch
quit
積丹尼 Dan Jacobson <jidanni <at> jidanni.org> 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?
[v1-0001-Split-shr-copy-url-dwim-behavior-into-separate-fu.patch (text/x-diff, inline)]
From af9fb0ef26f6624c490d8177599e517ed1799ad5 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
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
Added tag(s) patch; removed tag(s) moreinfo.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Fri, 12 May 2017 01:14:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#26826
; Package
emacs
.
(Sat, 03 Jun 2017 03:40:02 GMT)
Full text and
rfc822 format available.
Message #21 received at 26826 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
npostavs <at> 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:
[v2-0001-Split-shr-copy-url-dwim-behavior-into-separate-fu.patch (text/x-diff, inline)]
From 7d3f680e204d8525f4d518777f7ace76ce000192 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#26826
; Package
emacs
.
(Sun, 02 Jul 2017 20:23:01 GMT)
Full text and
rfc822 format available.
Message #24 received at 26826 <at> debbugs.gnu.org (full text, mbox):
tags 26826 fixed
close 26826 26.1
quit
npostavs <at> users.sourceforge.net writes:
> npostavs <at> 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
Added tag(s) fixed.
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sun, 02 Jul 2017 20:23:03 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 26.1, send any further explanations to
26826 <at> debbugs.gnu.org and 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Request was from
npostavs <at> users.sourceforge.net
to
control <at> debbugs.gnu.org
.
(Sun, 02 Jul 2017 20:23:03 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 31 Jul 2017 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 16 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.