Protect against non-existant colour names.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Wed, 24 Nov 2010 10:56:03 +0000 (11:56 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Wed, 24 Nov 2010 10:56:03 +0000 (11:56 +0100)
lisp/ChangeLog
lisp/shr.el

index a00b9bb..93b07c1 100644 (file)
@@ -1,3 +1,7 @@
+2010-11-24  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * shr.el (shr-color-check): Protect against non-existant colour names.
+
 2010-11-24  Julien Danjou  <julien@danjou.info>
 
        * shr.el (shr-insert-color-overlay): Remove specific rgb() check.
index fc1286e..36c8d70 100644 (file)
@@ -496,15 +496,18 @@ START, and END."
 (autoload 'shr-color->hexadecimal "shr-color")
 (defun shr-color-check (fg &optional bg)
   "Check that FG is visible on BG."
-  (shr-color-visible (or (shr-color->hexadecimal bg)
-                         (frame-parameter nil 'background-color))
-                     (shr-color->hexadecimal fg) (not bg)))
+  (let ((hex-color (shr-color->hexadecimal fg)))
+    (when hex-color
+      (shr-color-visible (or (shr-color->hexadecimal bg)
+                            (frame-parameter nil 'background-color))
+                        hex-color (not bg)))))
 
 (defun shr-insert-color-overlay (color start end)
   (when color
-    (let ((overlay (make-overlay start end)))
-      (overlay-put overlay 'face (cons 'foreground-color
-                                      (cadr (shr-color-check color)))))))
+    (let ((new-color (cadr (shr-color-check color))))
+      (when new-color
+       (overlay-put (make-overlay start end) 'face
+                    (cons 'foreground-color new-color))))))
 
 ;;; Tag-specific rendering rules.