]> git.eshelyaron.com Git - emacs.git/commitdiff
Replace NUL characters when calling into libxml
authorRobert Pluim <rpluim@gmail.com>
Tue, 26 Feb 2019 15:37:09 +0000 (16:37 +0100)
committerRobert Pluim <rpluim@gmail.com>
Wed, 27 Feb 2019 16:19:21 +0000 (17:19 +0100)
2019-02-27  Robert Pluim  <rpluim@gmail.com>

* 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

index d37a48126c1015dda9bf6713796dda1e16fcfa4e..3ec6c1cfd3b6542de2fbe995ae6ab06cb9b98306 100644 (file)
@@ -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)))))