]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix `eww-display-html' bug when passed an explicit DOM
authorLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 3 Nov 2014 00:30:41 +0000 (01:30 +0100)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Mon, 3 Nov 2014 00:30:41 +0000 (01:30 +0100)
(eww-display-html): Don't try to decode the text if we've been
passed in a pre-parsed DOM.

lisp/ChangeLog
lisp/net/eww.el

index ddd9fd787bb3031d950e5a750f86f61b8ee3641a..2288bba4c5e47fdf67cd7d89db98779c6b021de0 100644 (file)
@@ -5,6 +5,8 @@
        (eww-readable): Decode the saved text correctly.
        (eww-readable): Save the history before displaying so that we can
        go back to the non-readable version.
+       (eww-display-html): Don't try to decode the text if we've been
+       passed in a pre-parsed DOM.
 
 2014-11-02  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
index 6060062abb3329922a244073627f5daaf50dac38..954810ad0c974ff956f839a21ce97c941d598f03 100644 (file)
@@ -256,16 +256,18 @@ word(s) will be searched for via `eww-search-prefix'."
 (defun eww-display-html (charset url &optional document point)
   (or (fboundp 'libxml-parse-html-region)
       (error "This function requires Emacs to be compiled with libxml2"))
-  (unless (eq charset 'utf-8)
-    (condition-case nil
-       (decode-coding-region (point) (point-max) charset)
-      (coding-system-error nil)))
   (let ((document
         (or document
             (list
              'base (list (cons 'href url))
-             (libxml-parse-html-region (point) (point-max)))))
-       (source (buffer-substring (point) (point-max))))
+             (progn
+               (unless (eq charset 'utf-8)
+                 (condition-case nil
+                     (decode-coding-region (point) (point-max) charset)
+                   (coding-system-error nil)))
+               (libxml-parse-html-region (point) (point-max))))))
+       (source (and (null document)
+                    (buffer-substring (point) (point-max)))))
     (eww-setup-buffer)
     (setq eww-current-source source
          eww-current-dom document)