summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2018-04-13 17:11:07 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2018-04-13 17:11:07 +0200
commitc194be368cbbedd31092c22bd3a5b25113a83ac9 (patch)
treed7f42bb052c6ea2398b653c9198b751e2be72b52
parentbd7601f21b4627d91d8cccbd8ccd7666d774a083 (diff)
downloademacs-c194be368cbbedd31092c22bd3a5b25113a83ac9.tar.gz
Notify the user a bit more before clicking IDNA links
* lisp/net/shr.el (shr-urlify): Show the puny-encoded domain name in the mouseover string (bug#25600).
-rw-r--r--lisp/net/shr.el24
1 files changed, 18 insertions, 6 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 2dc1036e412..aa62e724636 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -38,6 +38,7 @@
(require 'seq)
(require 'svg)
(require 'image)
+(require 'puny)
(defgroup shr nil
"Simple HTML Renderer"
@@ -1209,12 +1210,23 @@ START, and END. Note that START and END should be markers."
(add-text-properties
start (point)
(list 'shr-url url
- 'help-echo (let ((iri (or (ignore-errors
- (decode-coding-string
- (url-unhex-string url)
- 'utf-8 t))
- url)))
- (if title (format "%s (%s)" iri title) iri))
+ 'help-echo (let ((parsed (url-generic-parse-url
+ (or (ignore-errors
+ (decode-coding-string
+ (url-unhex-string url)
+ 'utf-8 t))
+ url)))
+ iri)
+ ;; If we have an IDNA domain, then show the
+ ;; decoded version in the mouseover to let the
+ ;; user know that there's something possibly
+ ;; fishy.
+ (setf (url-host parsed)
+ (puny-encode-domain (url-host parsed)))
+ (setq iri (url-recreate-url parsed))
+ (if title
+ (format "%s (%s)" iri title)
+ iri))
'follow-link t
'mouse-face 'highlight))
;; Don't overwrite any keymaps that are already in the buffer (i.e.,