From d07f3aae48242ad70e874c2d10fc15b7e1efa4d6 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 26 Feb 2019 16:37:09 +0100 Subject: [PATCH] Replace NUL characters when calling into libxml 2019-02-27 Robert Pluim * lisp/net/eww.el (eww-display-html): Replace NUL characters with "\0", as libxml can't handle embedded NULLs. (Bug#34469) --- lisp/net/eww.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index d37a48126c1..3ec6c1cfd3b 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -470,10 +470,12 @@ Currently this means either text/html or application/xhtml+xml." (condition-case nil (decode-coding-region (point) (point-max) encode) (coding-system-error nil)) - (save-excursion - ;; Remove CRLF before parsing. - (while (re-search-forward "\r$" nil t) - (replace-match "" t t))) + (save-excursion + ;; Remove CRLF and NULL before parsing. + (while (re-search-forward "\\(\r$\\)\\|\\(\000\\)" nil t) + (replace-match (if (match-beginning 1) + "" + "\\0") t t))) (libxml-parse-html-region (point) (point-max)))))) (source (and (null document) (buffer-substring (point) (point-max))))) -- 2.39.2