From a005f610188cb025216b101f06b66fae026053d8 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Tue, 9 Dec 2014 04:21:57 +0100 Subject: [PATCH] Make eww mark valid/invalid https pages * lisp/net/eww.el (eww-update-header-line-format): Mark valid/invalid certificates in the header line. (eww-invalid-certificate, eww-valid-certificate): New faces. --- etc/NEWS | 4 ++++ lisp/ChangeLog | 6 ++++++ lisp/net/eww.el | 46 ++++++++++++++++++++++++++++++++++++---------- 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 2b407775d4c..4bca9e9ebc1 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -228,6 +228,10 @@ details. *** The new `S' command will list all eww buffers, and allow managing them. +--- +*** https pages with valid certificates have headers marked in green, while +invalid certificates are marked in red. + ** Message mode *** text/html messages that contain inline image parts will be diff --git a/lisp/ChangeLog b/lisp/ChangeLog index df057ac1070..e2dbe92c663 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2014-12-09 Lars Magne Ingebrigtsen + + * net/eww.el (eww-update-header-line-format): Mark valid/invalid + certificates in the header line. + (eww-invalid-certificate, eww-valid-certificate): New faces. + 2014-12-09 Fabián Ezequiel Gallina * progmodes/python.el (inferior-python-mode): Set diff --git a/lisp/net/eww.el b/lisp/net/eww.el index ed88c00af7c..c6d3bbceda2 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -199,6 +199,20 @@ See also `eww-form-checkbox-selected-symbol'." :version "24.4" :group 'eww) +(defface eww-invalid-certificate + '((default :weight bold) + (((class color)) :foreground "red")) + "Face for web pages with invalid certificates." + :version "25.1" + :group 'eww) + +(defface eww-valid-certificate + '((default :weight bold) + (((class color)) :foreground "ForestGreen")) + "Face for web pages with valid certificates." + :version "25.1" + :group 'eww) + (defvar eww-data nil) (defvar eww-history nil) (defvar eww-history-position 0) @@ -300,6 +314,9 @@ See the `eww-search-prefix' variable for the search engine used." "text/html")) "utf-8")))) (data-buffer (current-buffer))) + ;; Save the https peer status. + (with-current-buffer buffer + (plist-put eww-data :peer (plist-get status :peer))) (unwind-protect (progn (cond @@ -444,16 +461,25 @@ See the `eww-search-prefix' variable for the search engine used." (put-text-property start (point) 'keymap eww-link-keymap))) (defun eww-update-header-line-format () - (if eww-header-line-format - (setq header-line-format - (replace-regexp-in-string - "%" "%%" - ;; FIXME? Title can be blank. Default to, eg, last component - ;; of url? - (format-spec eww-header-line-format - `((?u . ,(or (plist-get eww-data :url) "")) - (?t . ,(or (plist-get eww-data :title) "")))))) - (setq header-line-format nil))) + (setq header-line-format + (and eww-header-line-format + (let ((title (plist-get eww-data :title)) + (peer (plist-get eww-data :peer))) + (when (zerop (length title)) + (setq title "[untitled]")) + ;; This connection has is https. + (when peer + (setq title + (propertize title 'face + (if (plist-get peer :warnings) + 'eww-invalid-certificate + 'eww-valid-certificate)))) + (replace-regexp-in-string + "%" "%%" + (format-spec + eww-header-line-format + `((?u . ,(or (plist-get eww-data :url) "")) + (?t . ,title)))))))) (defun eww-tag-title (dom) (plist-put eww-data :title -- 2.39.2