emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c194be3: Notify the user a bit more before clicking


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master c194be3: Notify the user a bit more before clicking IDNA links
Date: Fri, 13 Apr 2018 11:11:26 -0400 (EDT)

branch: master
commit c194be368cbbedd31092c22bd3a5b25113a83ac9
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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 2dc1036..aa62e72 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.,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]