]> code.delx.au - gnu-emacs/blobdiff - lisp/net/eww.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / net / eww.el
index 48bf556a526e255fd5934cc215a4ef02d911aefe..3c2e74799afc6cbc810f3fdf1656a8b1a0f6e0da 100644 (file)
@@ -31,6 +31,7 @@
 (require 'url-queue)
 (require 'url-util)                    ; for url-get-url-at-point
 (require 'mm-url)
+(require 'puny)
 (eval-when-compile (require 'subr-x)) ;; for string-trim
 
 (defgroup eww nil
@@ -275,6 +276,13 @@ word(s) will be searched for via `eww-search-prefix'."
            (setq url (concat eww-search-prefix
                              (replace-regexp-in-string " " "+" url))))))
   (eww-setup-buffer)
+  ;; Check whether the domain only uses "Highly Restricted" Unicode
+  ;; IDNA characters.  If not, transform to punycode to indicate that
+  ;; there may be funny business going on.
+  (let ((parsed (url-generic-parse-url url)))
+    (unless (puny-highly-restrictive-domain-p (url-host parsed))
+      (setf (url-host parsed) (puny-encode-domain (url-host parsed)))
+      (setq url (url-recreate-url parsed))))
   (plist-put eww-data :url url)
   (plist-put eww-data :title "")
   (eww-update-header-line-format)
@@ -409,9 +417,11 @@ Currently this means either text/html or application/xhtml+xml."
            (shr-target-id (url-target (url-generic-parse-url url)))
            (shr-external-rendering-functions
              (append
+              shr-external-rendering-functions
               '((title . eww-tag-title)
                 (form . eww-tag-form)
                 (input . eww-tag-input)
+                (button . eww-form-submit)
                 (textarea . eww-tag-textarea)
                 (select . eww-tag-select)
                 (link . eww-tag-link)
@@ -680,6 +690,7 @@ the like."
     (define-key map "E" 'eww-set-character-encoding)
     (define-key map "S" 'eww-list-buffers)
     (define-key map "F" 'eww-toggle-fonts)
+    (define-key map [(meta C)] 'eww-toggle-colors)
 
     (define-key map "b" 'eww-add-bookmark)
     (define-key map "B" 'eww-list-bookmarks)
@@ -704,6 +715,8 @@ the like."
        ["Add bookmark" eww-add-bookmark t]
        ["List bookmarks" eww-list-bookmarks t]
        ["List cookies" url-cookie-list t]
+       ["Toggle fonts" eww-toggle-fonts t]
+       ["Toggle colors" eww-toggle-colors t]
        ["Character Encoding" eww-set-character-encoding]))
     map))
 
@@ -1493,6 +1506,15 @@ If CHARSET is nil then use UTF-8."
             "off"))
   (eww-reload))
 
+(defun eww-toggle-colors ()
+  "Toggle whether to use HTML-specified colors or not."
+  (interactive)
+  (message "Colors are now %s"
+          (if (setq shr-use-colors (not shr-use-colors))
+              "on"
+            "off"))
+  (eww-reload))
+
 ;;; Bookmarks code
 
 (defvar eww-bookmarks nil)