From c194be368cbbedd31092c22bd3a5b25113a83ac9 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Fri, 13 Apr 2018 17:11:07 +0200 Subject: [PATCH] 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). --- lisp/net/shr.el | 24 ++++++++++++++++++------ 1 file 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., -- 2.39.5