aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2018-04-13 17:11:07 +0200
committerLars Ingebrigtsen2018-04-13 17:11:07 +0200
commitc194be368cbbedd31092c22bd3a5b25113a83ac9 (patch)
treed7f42bb052c6ea2398b653c9198b751e2be72b52
parentbd7601f21b4627d91d8cccbd8ccd7666d774a083 (diff)
downloademacs-c194be368cbbedd31092c22bd3a5b25113a83ac9.tar.gz
emacs-c194be368cbbedd31092c22bd3a5b25113a83ac9.zip
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 @@
38(require 'seq) 38(require 'seq)
39(require 'svg) 39(require 'svg)
40(require 'image) 40(require 'image)
41(require 'puny)
41 42
42(defgroup shr nil 43(defgroup shr nil
43 "Simple HTML Renderer" 44 "Simple HTML Renderer"
@@ -1209,12 +1210,23 @@ START, and END. Note that START and END should be markers."
1209 (add-text-properties 1210 (add-text-properties
1210 start (point) 1211 start (point)
1211 (list 'shr-url url 1212 (list 'shr-url url
1212 'help-echo (let ((iri (or (ignore-errors 1213 'help-echo (let ((parsed (url-generic-parse-url
1213 (decode-coding-string 1214 (or (ignore-errors
1214 (url-unhex-string url) 1215 (decode-coding-string
1215 'utf-8 t)) 1216 (url-unhex-string url)
1216 url))) 1217 'utf-8 t))
1217 (if title (format "%s (%s)" iri title) iri)) 1218 url)))
1219 iri)
1220 ;; If we have an IDNA domain, then show the
1221 ;; decoded version in the mouseover to let the
1222 ;; user know that there's something possibly
1223 ;; fishy.
1224 (setf (url-host parsed)
1225 (puny-encode-domain (url-host parsed)))
1226 (setq iri (url-recreate-url parsed))
1227 (if title
1228 (format "%s (%s)" iri title)
1229 iri))
1218 'follow-link t 1230 'follow-link t
1219 'mouse-face 'highlight)) 1231 'mouse-face 'highlight))
1220 ;; Don't overwrite any keymaps that are already in the buffer (i.e., 1232 ;; Don't overwrite any keymaps that are already in the buffer (i.e.,