From 029788dbb0a42252078d4837c8c1854eaf8f506e Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Mon, 3 Nov 2014 01:30:41 +0100 Subject: [PATCH] Fix `eww-display-html' bug when passed an explicit DOM (eww-display-html): Don't try to decode the text if we've been passed in a pre-parsed DOM. --- lisp/ChangeLog | 2 ++ lisp/net/eww.el | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ddd9fd787bb..2288bba4c5e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -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 diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 6060062abb3..954810ad0c9 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -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) -- 2.11.4.GIT