emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master a005f61 2/2: Make eww mark valid/invalid https page


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master a005f61 2/2: Make eww mark valid/invalid https pages
Date: Tue, 09 Dec 2014 03:22:04 +0000

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

    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 2b40777..4bca9e9 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 df057ac..e2dbe92 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-09  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * 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  <address@hidden>
 
        * progmodes/python.el (inferior-python-mode): Set
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index ed88c00..c6d3bbc 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



reply via email to

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